00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00062 void arm_float_to_q7(
00063 float32_t * pSrc,
00064 q7_t * pDst,
00065 uint32_t blockSize)
00066 {
00067 float32_t *pIn = pSrc;
00068 uint32_t blkCnt;
00069
00070 #ifdef ARM_MATH_ROUNDING
00071
00072 float32_t in;
00073
00074 #endif
00075
00076
00077 blkCnt = blockSize >> 3u;
00078
00079
00080
00081 while(blkCnt > 0u)
00082 {
00083 #ifdef ARM_MATH_ROUNDING
00084
00085
00086 in = *pIn++;
00087 in = (in * 128);
00088 in += in > 0 ? 0.5 : -0.5;
00089 #ifdef CCS
00090 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00091 #else
00092 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00093 #endif // #ifdef CCS
00094
00095 in = *pIn++;
00096 in = (in * 128);
00097 in += in > 0 ? 0.5 : -0.5;
00098 #ifdef CCS
00099 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00100 #else
00101 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00102 #endif // #ifdef CCS
00103
00104 in = *pIn++;
00105 in = (in * 128);
00106 in += in > 0 ? 0.5 : -0.5;
00107 #ifdef CCS
00108 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00109 #else
00110 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00111 #endif // #ifdef CCS
00112
00113 in = *pIn++;
00114 in = (in * 128);
00115 in += in > 0 ? 0.5 : -0.5;
00116 #ifdef CCS
00117 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00118 #else
00119 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00120 #endif // #ifdef CCS
00121
00122 in = *pIn++;
00123 in = (in * 128);
00124 in += in > 0 ? 0.5 : -0.5;
00125 #ifdef CCS
00126 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00127 #else
00128 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00129 #endif // #ifdef CCS
00130
00131 in = *pIn++;
00132 in = (in * 128);
00133 in += in > 0 ? 0.5 : -0.5;
00134 #ifdef CCS
00135 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00136 #else
00137 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00138 #endif // #ifdef CCS
00139
00140 in = *pIn++;
00141 in = (in * 128);
00142 in += in > 0 ? 0.5 : -0.5;
00143 #ifdef CCS
00144 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00145 #else
00146 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00147 #endif // #ifdef CCS
00148
00149 in = *pIn++;
00150 in = (in * 128);
00151 in += in > 0 ? 0.5 : -0.5;
00152 #ifdef CCS
00153 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00154 #else
00155 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00156 #endif // #ifdef CCS
00157
00158 #else
00159
00160
00161
00162 #ifdef CCS
00163 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00164 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00165 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00166 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00167 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00168 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00169 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00170 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00171 #else
00172 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00173 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00174 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00175 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00176 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00177 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00178 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00179 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00180 #endif // #ifdef CCS
00181
00182 #endif // #ifdef ARM_MATH_ROUNDING
00183
00184
00185 blkCnt--;
00186 }
00187
00188
00189
00190 blkCnt = blockSize % 0x8u;
00191
00192 while(blkCnt > 0u)
00193 {
00194 #ifdef ARM_MATH_ROUNDING
00195
00196
00197 in = *pIn++;
00198 in = (in * 128);
00199 in += in > 0 ? 0.5 : -0.5;
00200 #ifdef CCS
00201 *pDst++ = (q7_t) (__SSATA((q15_t) (in), 0, 8));
00202 #else
00203 *pDst++ = (q7_t) (__SSAT((q15_t) (in), 8));
00204 #endif // #ifdef CCS
00205
00206 #else
00207
00208
00209
00210 #ifdef CCS
00211 *pDst++ = __SSATA((q31_t) (*pIn++ * 128.0f), 0, 8);
00212 #else
00213 *pDst++ = __SSAT((q31_t) (*pIn++ * 128.0f), 8);
00214 #endif // #ifdef CCS
00215
00216 #endif // #ifdef ARM_MATH_ROUNDING
00217
00218
00219 blkCnt--;
00220 }
00221 }
00222