1 #include "DECIMF32.h" 2 #include <stdio.h> 3 #include "Error.h" 4 5 #define SNR_THRESHOLD 120 6 7 /* 8 9 Reference patterns are generated with 10 a double precision computation. 11 12 */ 13 #define REL_ERROR (8.0e-4) 14 15 test_fir_decimate_f32()16 void DECIMF32::test_fir_decimate_f32() 17 { 18 int nbTests; 19 int nb; 20 uint32_t *pConfig = config.ptr(); 21 22 const float32_t * pSrc = input.ptr(); 23 float32_t * pDst = output.ptr(); 24 float32_t * pCoefs = coefs.ptr(); 25 26 nbTests=config.nbSamples() / 4; 27 28 for(nb=0;nb < nbTests; nb++) 29 { 30 31 this->q = pConfig[0]; 32 this->numTaps = pConfig[1]; 33 this->blocksize = pConfig[2]; 34 this->refsize = pConfig[3]; 35 36 37 pConfig += 4; 38 39 this->status=arm_fir_decimate_init_f32(&(this->S), 40 this->numTaps, 41 this->q, 42 pCoefs, 43 state.ptr(), 44 this->blocksize); 45 46 47 48 ASSERT_TRUE(this->status == ARM_MATH_SUCCESS); 49 50 arm_fir_decimate_f32( 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_REL_ERROR(output,ref,REL_ERROR); 68 69 } 70 test_fir_interpolate_f32()71 void DECIMF32::test_fir_interpolate_f32() 72 { 73 int nbTests; 74 int nb; 75 uint32_t *pConfig = config.ptr(); 76 77 const float32_t * pSrc = input.ptr(); 78 float32_t * pDst = output.ptr(); 79 float32_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 93 pConfig += 4; 94 95 this->status=arm_fir_interpolate_init_f32(&(this->SI), 96 this->q, 97 this->numTaps, 98 pCoefs, 99 state.ptr(), 100 this->blocksize); 101 102 103 104 ASSERT_TRUE(this->status == ARM_MATH_SUCCESS); 105 106 arm_fir_interpolate_f32( 107 &(this->SI), 108 pSrc, 109 pDst, 110 this->blocksize); 111 112 pSrc += this->blocksize; 113 pDst += this->refsize; 114 115 pCoefs += this->numTaps; 116 } 117 118 119 ASSERT_EMPTY_TAIL(output); 120 121 ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD); 122 123 ASSERT_REL_ERROR(output,ref,REL_ERROR); 124 125 } 126 127 setUp(Testing::testID_t id,std::vector<Testing::param_t> & params,Client::PatternMgr * mgr)128 void DECIMF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr) 129 { 130 131 (void)params; 132 133 switch(id) 134 { 135 case DECIMF32::TEST_FIR_DECIMATE_F32_1: 136 config.reload(DECIMF32::CONFIGSDECIMF32_ID,mgr); 137 138 input.reload(DECIMF32::INPUT1_F32_ID,mgr); 139 coefs.reload(DECIMF32::COEFS1_F32_ID,mgr); 140 141 ref.reload(DECIMF32::REF1_DECIM_F32_ID,mgr); 142 state.create(16 + 768 - 1,DECIMF32::STATE_F32_ID,mgr); 143 144 break; 145 146 case DECIMF32::TEST_FIR_INTERPOLATE_F32_2: 147 config.reload(DECIMF32::CONFIGSINTERPF32_ID,mgr); 148 149 input.reload(DECIMF32::INPUT2_F32_ID,mgr); 150 coefs.reload(DECIMF32::COEFS2_F32_ID,mgr); 151 152 ref.reload(DECIMF32::REF2_INTERP_F32_ID,mgr); 153 state.create(16 + 768 - 1,DECIMF32::STATE_F32_ID,mgr); 154 155 break; 156 157 158 } 159 160 161 162 163 output.create(ref.nbSamples(),DECIMF32::OUT_F32_ID,mgr); 164 } 165 tearDown(Testing::testID_t id,Client::PatternMgr * mgr)166 void DECIMF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr) 167 { 168 (void)id; 169 output.dump(mgr); 170 } 171