1 #include "DECIMQ15.h" 2 #include <stdio.h> 3 #include "Error.h" 4 5 #define SNR_THRESHOLD 70 6 7 /* 8 9 Reference patterns are generated with 10 a double precision computation. 11 12 */ 13 #define ABS_ERROR_Q15 ((q15_t)5) 14 #define ABS_ERROR_Q63 ((q63_t)(1<<17)) 15 16 #define ONEHALF 0x40000000 17 18 test_fir_decimate_q15()19 void DECIMQ15::test_fir_decimate_q15() 20 { 21 int nbTests; 22 int nb; 23 uint32_t *pConfig = config.ptr(); 24 25 const q15_t * pSrc = input.ptr(); 26 q15_t * pDst = output.ptr(); 27 q15_t * pCoefs = coefs.ptr(); 28 29 nbTests=config.nbSamples() / 4; 30 31 for(nb=0;nb < nbTests; nb++) 32 { 33 34 this->q = pConfig[0]; 35 this->numTaps = pConfig[1]; 36 this->blocksize = pConfig[2]; 37 this->refsize = pConfig[3]; 38 39 pConfig += 4; 40 41 this->status=arm_fir_decimate_init_q15(&(this->S), 42 this->numTaps, 43 this->q, 44 pCoefs, 45 state.ptr(), 46 this->blocksize); 47 48 ASSERT_TRUE(this->status == ARM_MATH_SUCCESS); 49 50 arm_fir_decimate_q15( 51 &(this->S), 52 pSrc, 53 pDst, 54 this->blocksize); 55 56 pSrc += this->blocksize; 57 pDst += this->refsize; 58 59 pCoefs += this->numTaps; 60 } 61 62 63 ASSERT_EMPTY_TAIL(output); 64 65 ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD); 66 67 ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15); 68 69 } 70 test_fir_interpolate_q15()71 void DECIMQ15::test_fir_interpolate_q15() 72 { 73 int nbTests; 74 int nb; 75 uint32_t *pConfig = config.ptr(); 76 77 const q15_t * pSrc = input.ptr(); 78 q15_t * pDst = output.ptr(); 79 q15_t * pCoefs = coefs.ptr(); 80 81 nbTests=config.nbSamples() / 4; 82 83 for(nb=0;nb < nbTests; nb++) 84 { 85 86 this->q = pConfig[0]; 87 this->numTaps = pConfig[1]; 88 this->blocksize = pConfig[2]; 89 this->refsize = pConfig[3]; 90 91 92 pConfig += 4; 93 94 this->status=arm_fir_interpolate_init_q15(&(this->SI), 95 this->q, 96 this->numTaps, 97 pCoefs, 98 state.ptr(), 99 this->blocksize); 100 101 102 103 ASSERT_TRUE(this->status == ARM_MATH_SUCCESS); 104 105 arm_fir_interpolate_q15( 106 &(this->SI), 107 pSrc, 108 pDst, 109 this->blocksize); 110 111 pSrc += this->blocksize; 112 pDst += this->refsize; 113 114 pCoefs += this->numTaps; 115 } 116 117 118 ASSERT_EMPTY_TAIL(output); 119 120 ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD); 121 122 ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15); 123 124 } 125 setUp(Testing::testID_t id,std::vector<Testing::param_t> & params,Client::PatternMgr * mgr)126 void DECIMQ15::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr) 127 { 128 129 (void)params; 130 config.reload(DECIMQ15::CONFIGSDECIMQ15_ID,mgr); 131 132 133 switch(id) 134 { 135 case DECIMQ15::TEST_FIR_DECIMATE_Q15_1: 136 config.reload(DECIMQ15::CONFIGSDECIMQ15_ID,mgr); 137 input.reload(DECIMQ15::INPUT1_Q15_ID,mgr); 138 coefs.reload(DECIMQ15::COEFS1_Q15_ID,mgr); 139 140 ref.reload(DECIMQ15::REF1_DECIM_Q15_ID,mgr); 141 state.create(16 + 768 - 1,DECIMQ15::STATE_Q15_ID,mgr); 142 143 break; 144 145 case DECIMQ15::TEST_FIR_INTERPOLATE_Q15_2: 146 config.reload(DECIMQ15::CONFIGSINTERPQ15_ID,mgr); 147 148 input.reload(DECIMQ15::INPUT2_Q15_ID,mgr); 149 coefs.reload(DECIMQ15::COEFS2_Q15_ID,mgr); 150 151 ref.reload(DECIMQ15::REF2_INTERP_Q15_ID,mgr); 152 state.create(16 + 768 - 1,DECIMQ15::STATE_Q15_ID,mgr); 153 154 break; 155 156 } 157 158 159 160 161 output.create(ref.nbSamples(),DECIMQ15::OUT_Q15_ID,mgr); 162 } 163 tearDown(Testing::testID_t id,Client::PatternMgr * mgr)164 void DECIMQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr) 165 { 166 (void)id; 167 output.dump(mgr); 168 } 169