ref.h 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  1. #ifndef _REF_H
  2. #define _REF_H
  3. #include <math.h>
  4. #include <stdint.h>
  5. #include "arm_math.h"
  6. #ifdef __cplusplus
  7. extern "C"
  8. {
  9. #endif
  10. #ifndef PI
  11. #define PI 3.14159265358979f
  12. #endif
  13. /**
  14. * @brief 8-bit fractional data type in 1.7 format.
  15. */
  16. // typedef int8_t q7_t;
  17. /**
  18. * @brief 16-bit fractional data type in 1.15 format.
  19. */
  20. // typedef int16_t q15_t;
  21. /**
  22. * @brief 32-bit fractional data type in 1.31 format.
  23. */
  24. // typedef int32_t q31_t;
  25. /**
  26. * @brief 64-bit fractional data type in 1.63 format.
  27. */
  28. // typedef int64_t q63_t;
  29. /**
  30. * @brief 32-bit floating-point type definition.
  31. */
  32. // typedef float float32_t;
  33. /**
  34. * @brief 64-bit floating-point type definition.
  35. */
  36. // typedef double float64_t;
  37. /**
  38. * @brief Error status returned by some functions in the library.
  39. */
  40. typedef enum
  41. {
  42. REF_Q7 = 0,
  43. REF_Q15,
  44. REF_Q31,
  45. REF_F32,
  46. } dataType;
  47. #ifndef FLT_MAX
  48. #define FLT_MAX 3.40282347e+38F
  49. #endif
  50. #define DBL_MAX 1.79769313486231571e+308
  51. #ifndef FLT_MIN
  52. #define FLT_MIN 1.175494351e-38F
  53. #endif
  54. #define DBL_MIN 2.22507385850720138e-308
  55. #define SCHAR_MIN (-128)
  56. /* mimimum value for an object of type signed char */
  57. #define SCHAR_MAX 127
  58. /* maximum value for an object of type signed char */
  59. #define UCHAR_MAX 255
  60. /* maximum value for an object of type unsigned char */
  61. #define SHRT_MIN (-0x8000)
  62. /* minimum value for an object of type short int */
  63. #define SHRT_MAX 0x7fff
  64. /* maximum value for an object of type short int */
  65. #define USHRT_MAX 65535
  66. /* maximum value for an object of type unsigned short int */
  67. #define INT_MIN (~0x7fffffff) /* -2147483648 and 0x80000000 are unsigned */
  68. /* minimum value for an object of type int */
  69. #define INT_MAX 0x7fffffff
  70. /* maximum value for an object of type int */
  71. #define UINT_MAX 0xffffffffU
  72. /* maximum value for an object of type unsigned int */
  73. #define LONG_MIN (~0x7fffffffL)
  74. /* minimum value for an object of type long int */
  75. #define LONG_MAX 0x7fffffffL
  76. /* maximum value for an object of type long int */
  77. #define ULONG_MAX 0xffffffffUL
  78. /* maximum value for an object of type unsigned long int */
  79. /*
  80. * Ref Lib Global Variables
  81. */
  82. extern float32_t scratchArray[];
  83. extern arm_cfft_instance_f32 ref_cfft_sR_f32_len8192;
  84. /*
  85. * Ref Lib Functions
  86. */
  87. /*
  88. * Helper Functions
  89. */
  90. q31_t ref_sat_n(q31_t num, uint32_t bits);
  91. q31_t ref_sat_q31(q63_t num);
  92. q15_t ref_sat_q15(q31_t num);
  93. q7_t ref_sat_q7(q15_t num);
  94. float32_t ref_pow(float32_t a, uint32_t b);
  95. extern float32_t tempMatrixArray[];
  96. float32_t ref_detrm(float32_t *pSrc, float32_t *temp, uint32_t size);
  97. void ref_cofact(float32_t *pSrc, float32_t *pDst, float32_t *temp, uint32_t size);
  98. float64_t ref_detrm64(float64_t *pSrc, float64_t *temp, uint32_t size);
  99. void ref_cofact64(float64_t *pSrc, float64_t *pDst, float64_t *temp, uint32_t size);
  100. /*
  101. * Basic Math Functions
  102. */
  103. void ref_abs_f32(
  104. float32_t * pSrc,
  105. float32_t * pDst,
  106. uint32_t blockSize);
  107. void ref_abs_q31(
  108. q31_t * pSrc,
  109. q31_t * pDst,
  110. uint32_t blockSize);
  111. void ref_abs_q15(
  112. q15_t * pSrc,
  113. q15_t * pDst,
  114. uint32_t blockSize);
  115. void ref_abs_q7(
  116. q7_t * pSrc,
  117. q7_t * pDst,
  118. uint32_t blockSize);
  119. void ref_add_f32(
  120. float32_t * pSrcA,
  121. float32_t * pSrcB,
  122. float32_t * pDst,
  123. uint32_t blockSize);
  124. void ref_add_q31(
  125. q31_t * pSrcA,
  126. q31_t * pSrcB,
  127. q31_t * pDst,
  128. uint32_t blockSize);
  129. void ref_add_q15(
  130. q15_t * pSrcA,
  131. q15_t * pSrcB,
  132. q15_t * pDst,
  133. uint32_t blockSize);
  134. void ref_add_q7(
  135. q7_t * pSrcA,
  136. q7_t * pSrcB,
  137. q7_t * pDst,
  138. uint32_t blockSize);
  139. void ref_dot_prod_f32(
  140. float32_t * pSrcA,
  141. float32_t * pSrcB,
  142. uint32_t blockSize,
  143. float32_t * result);
  144. void ref_dot_prod_q31(
  145. q31_t * pSrcA,
  146. q31_t * pSrcB,
  147. uint32_t blockSize,
  148. q63_t * result);
  149. void ref_dot_prod_q15(
  150. q15_t * pSrcA,
  151. q15_t * pSrcB,
  152. uint32_t blockSize,
  153. q63_t * result);
  154. void ref_dot_prod_q7(
  155. q7_t * pSrcA,
  156. q7_t * pSrcB,
  157. uint32_t blockSize,
  158. q31_t * result);
  159. void ref_mult_f32(
  160. float32_t * pSrcA,
  161. float32_t * pSrcB,
  162. float32_t * pDst,
  163. uint32_t blockSize);
  164. void ref_mult_q31(
  165. q31_t * pSrcA,
  166. q31_t * pSrcB,
  167. q31_t * pDst,
  168. uint32_t blockSize);
  169. void ref_mult_q15(
  170. q15_t * pSrcA,
  171. q15_t * pSrcB,
  172. q15_t * pDst,
  173. uint32_t blockSize);
  174. void ref_mult_q7(
  175. q7_t * pSrcA,
  176. q7_t * pSrcB,
  177. q7_t * pDst,
  178. uint32_t blockSize);
  179. void ref_negate_f32(
  180. float32_t * pSrc,
  181. float32_t * pDst,
  182. uint32_t blockSize);
  183. void ref_negate_q31(
  184. q31_t * pSrc,
  185. q31_t * pDst,
  186. uint32_t blockSize);
  187. void ref_negate_q15(
  188. q15_t * pSrc,
  189. q15_t * pDst,
  190. uint32_t blockSize);
  191. void ref_negate_q7(
  192. q7_t * pSrc,
  193. q7_t * pDst,
  194. uint32_t blockSize);
  195. void ref_offset_f32(
  196. float32_t * pSrc,
  197. float32_t offset,
  198. float32_t * pDst,
  199. uint32_t blockSize);
  200. void ref_offset_q31(
  201. q31_t * pSrc,
  202. q31_t offset,
  203. q31_t * pDst,
  204. uint32_t blockSize);
  205. void ref_offset_q15(
  206. q15_t * pSrc,
  207. q15_t offset,
  208. q15_t * pDst,
  209. uint32_t blockSize);
  210. void ref_offset_q7(
  211. q7_t * pSrc,
  212. q7_t offset,
  213. q7_t * pDst,
  214. uint32_t blockSize);
  215. void ref_scale_f32(
  216. float32_t * pSrc,
  217. float32_t scale,
  218. float32_t * pDst,
  219. uint32_t blockSize);
  220. void ref_scale_q31(
  221. q31_t * pSrc,
  222. q31_t scaleFract,
  223. int8_t shift,
  224. q31_t * pDst,
  225. uint32_t blockSize);
  226. void ref_scale_q15(
  227. q15_t * pSrc,
  228. q15_t scaleFract,
  229. int8_t shift,
  230. q15_t * pDst,
  231. uint32_t blockSize);
  232. void ref_scale_q7(
  233. q7_t * pSrc,
  234. q7_t scaleFract,
  235. int8_t shift,
  236. q7_t * pDst,
  237. uint32_t blockSize);
  238. void ref_shift_q31(
  239. q31_t * pSrc,
  240. int8_t shiftBits,
  241. q31_t * pDst,
  242. uint32_t blockSize);
  243. void ref_shift_q15(
  244. q15_t * pSrc,
  245. int8_t shiftBits,
  246. q15_t * pDst,
  247. uint32_t blockSize);
  248. void ref_shift_q7(
  249. q7_t * pSrc,
  250. int8_t shiftBits,
  251. q7_t * pDst,
  252. uint32_t blockSize);
  253. void ref_sub_f32(
  254. float32_t * pSrcA,
  255. float32_t * pSrcB,
  256. float32_t * pDst,
  257. uint32_t blockSize);
  258. void ref_sub_q31(
  259. q31_t * pSrcA,
  260. q31_t * pSrcB,
  261. q31_t * pDst,
  262. uint32_t blockSize);
  263. void ref_sub_q15(
  264. q15_t * pSrcA,
  265. q15_t * pSrcB,
  266. q15_t * pDst,
  267. uint32_t blockSize);
  268. void ref_sub_q7(
  269. q7_t * pSrcA,
  270. q7_t * pSrcB,
  271. q7_t * pDst,
  272. uint32_t blockSize);
  273. /*
  274. * Complex Math Functions
  275. */
  276. void ref_cmplx_conj_f32(
  277. float32_t * pSrc,
  278. float32_t * pDst,
  279. uint32_t numSamples);
  280. void ref_cmplx_conj_q31(
  281. q31_t * pSrc,
  282. q31_t * pDst,
  283. uint32_t numSamples);
  284. void ref_cmplx_conj_q15(
  285. q15_t * pSrc,
  286. q15_t * pDst,
  287. uint32_t numSamples);
  288. void ref_cmplx_dot_prod_f32(
  289. float32_t * pSrcA,
  290. float32_t * pSrcB,
  291. uint32_t numSamples,
  292. float32_t * realResult,
  293. float32_t * imagResult);
  294. void ref_cmplx_dot_prod_q31(
  295. q31_t * pSrcA,
  296. q31_t * pSrcB,
  297. uint32_t numSamples,
  298. q63_t * realResult,
  299. q63_t * imagResult);
  300. void ref_cmplx_dot_prod_q15(
  301. q15_t * pSrcA,
  302. q15_t * pSrcB,
  303. uint32_t numSamples,
  304. q31_t * realResult,
  305. q31_t * imagResult);
  306. void ref_cmplx_mag_f32(
  307. float32_t * pSrc,
  308. float32_t * pDst,
  309. uint32_t numSamples);
  310. void ref_cmplx_mag_q31(
  311. q31_t * pSrc,
  312. q31_t * pDst,
  313. uint32_t numSamples);
  314. void ref_cmplx_mag_q15(
  315. q15_t * pSrc,
  316. q15_t * pDst,
  317. uint32_t numSamples);
  318. void ref_cmplx_mag_squared_f32(
  319. float32_t * pSrc,
  320. float32_t * pDst,
  321. uint32_t numSamples);
  322. void ref_cmplx_mag_squared_q31(
  323. q31_t * pSrc,
  324. q31_t * pDst,
  325. uint32_t numSamples);
  326. void ref_cmplx_mag_squared_q15(
  327. q15_t * pSrc,
  328. q15_t * pDst,
  329. uint32_t numSamples);
  330. void ref_cmplx_mult_cmplx_f32(
  331. float32_t * pSrcA,
  332. float32_t * pSrcB,
  333. float32_t * pDst,
  334. uint32_t numSamples);
  335. void ref_cmplx_mult_cmplx_q31(
  336. q31_t * pSrcA,
  337. q31_t * pSrcB,
  338. q31_t * pDst,
  339. uint32_t numSamples);
  340. void ref_cmplx_mult_cmplx_q15(
  341. q15_t * pSrcA,
  342. q15_t * pSrcB,
  343. q15_t * pDst,
  344. uint32_t numSamples);
  345. void ref_cmplx_mult_real_f32(
  346. float32_t * pSrcCmplx,
  347. float32_t * pSrcReal,
  348. float32_t * pCmplxDst,
  349. uint32_t numSamples);
  350. void ref_cmplx_mult_real_q31(
  351. q31_t * pSrcCmplx,
  352. q31_t * pSrcReal,
  353. q31_t * pCmplxDst,
  354. uint32_t numSamples);
  355. void ref_cmplx_mult_real_q15(
  356. q15_t * pSrcCmplx,
  357. q15_t * pSrcReal,
  358. q15_t * pCmplxDst,
  359. uint32_t numSamples);
  360. /*
  361. * Controller Functions
  362. */
  363. void ref_sin_cos_f32(
  364. float32_t theta,
  365. float32_t * pSinVal,
  366. float32_t * pCosVal);
  367. void ref_sin_cos_q31(
  368. q31_t theta,
  369. q31_t * pSinVal,
  370. q31_t * pCosVal);
  371. float32_t ref_pid_f32(
  372. arm_pid_instance_f32 * S,
  373. float32_t in);
  374. q31_t ref_pid_q31(
  375. arm_pid_instance_q31 * S,
  376. q31_t in);
  377. q15_t ref_pid_q15(
  378. arm_pid_instance_q15 * S,
  379. q15_t in);
  380. /*
  381. * Fast Math Functions
  382. */
  383. #define ref_sin_f32(a) sinf(a)
  384. q31_t ref_sin_q31(q31_t x);
  385. q15_t ref_sin_q15(q15_t x);
  386. #define ref_cos_f32(a) cosf(a)
  387. q31_t ref_cos_q31(q31_t x);
  388. q15_t ref_cos_q15(q15_t x);
  389. arm_status ref_sqrt_q31(q31_t in, q31_t * pOut);
  390. arm_status ref_sqrt_q15(q15_t in, q15_t * pOut);
  391. /*
  392. * Filtering Functions
  393. */
  394. void ref_biquad_cascade_df2T_f32(
  395. const arm_biquad_cascade_df2T_instance_f32 * S,
  396. float32_t * pSrc,
  397. float32_t * pDst,
  398. uint32_t blockSize);
  399. void ref_biquad_cascade_stereo_df2T_f32(
  400. const arm_biquad_cascade_stereo_df2T_instance_f32 * S,
  401. float32_t * pSrc,
  402. float32_t * pDst,
  403. uint32_t blockSize);
  404. void ref_biquad_cascade_df2T_f64(
  405. const arm_biquad_cascade_df2T_instance_f64 * S,
  406. float64_t * pSrc,
  407. float64_t * pDst,
  408. uint32_t blockSize);
  409. void ref_biquad_cascade_df1_f32(
  410. const arm_biquad_casd_df1_inst_f32 * S,
  411. float32_t * pSrc,
  412. float32_t * pDst,
  413. uint32_t blockSize);
  414. void ref_biquad_cas_df1_32x64_q31(
  415. const arm_biquad_cas_df1_32x64_ins_q31 * S,
  416. q31_t * pSrc,
  417. q31_t * pDst,
  418. uint32_t blockSize);
  419. void ref_biquad_cascade_df1_q31(
  420. const arm_biquad_casd_df1_inst_q31 * S,
  421. q31_t * pSrc,
  422. q31_t * pDst,
  423. uint32_t blockSize);
  424. void ref_biquad_cascade_df1_fast_q31(
  425. const arm_biquad_casd_df1_inst_q31 * S,
  426. q31_t * pSrc,
  427. q31_t * pDst,
  428. uint32_t blockSize);
  429. void ref_biquad_cascade_df1_fast_q15(
  430. const arm_biquad_casd_df1_inst_q15 * S,
  431. q15_t * pSrc,
  432. q15_t * pDst,
  433. uint32_t blockSize);
  434. void ref_biquad_cascade_df1_q15(
  435. const arm_biquad_casd_df1_inst_q15 * S,
  436. q15_t * pSrc,
  437. q15_t * pDst,
  438. uint32_t blockSize);
  439. void ref_conv_f32(
  440. float32_t * pSrcA,
  441. uint32_t srcALen,
  442. float32_t * pSrcB,
  443. uint32_t srcBLen,
  444. float32_t * pDst);
  445. arm_status ref_conv_partial_f32(
  446. float32_t * pSrcA,
  447. uint32_t srcALen,
  448. float32_t * pSrcB,
  449. uint32_t srcBLen,
  450. float32_t * pDst,
  451. uint32_t firstIndex,
  452. uint32_t numPoints);
  453. void ref_conv_q31(
  454. q31_t * pSrcA,
  455. uint32_t srcALen,
  456. q31_t * pSrcB,
  457. uint32_t srcBLen,
  458. q31_t * pDst);
  459. void ref_conv_fast_q31(
  460. q31_t * pSrcA,
  461. uint32_t srcALen,
  462. q31_t * pSrcB,
  463. uint32_t srcBLen,
  464. q31_t * pDst);
  465. arm_status ref_conv_partial_q31(
  466. q31_t * pSrcA,
  467. uint32_t srcALen,
  468. q31_t * pSrcB,
  469. uint32_t srcBLen,
  470. q31_t * pDst,
  471. uint32_t firstIndex,
  472. uint32_t numPoints);
  473. arm_status ref_conv_partial_fast_q31(
  474. q31_t * pSrcA,
  475. uint32_t srcALen,
  476. q31_t * pSrcB,
  477. uint32_t srcBLen,
  478. q31_t * pDst,
  479. uint32_t firstIndex,
  480. uint32_t numPoints);
  481. void ref_conv_q15(
  482. q15_t * pSrcA,
  483. uint32_t srcALen,
  484. q15_t * pSrcB,
  485. uint32_t srcBLen,
  486. q15_t * pDst);
  487. #define ref_conv_opt_q15(pSrcA, srcALen, pSrcB, srcBLen, pDst, \
  488. pScratch1, pScratch2) \
  489. ref_conv_q15(pSrcA, srcALen, pSrcB, srcBLen, pDst)
  490. void ref_conv_fast_q15(
  491. q15_t * pSrcA,
  492. uint32_t srcALen,
  493. q15_t * pSrcB,
  494. uint32_t srcBLen,
  495. q15_t * pDst);
  496. void ref_conv_fast_opt_q15(
  497. q15_t * pSrcA,
  498. uint32_t srcALen,
  499. q15_t * pSrcB,
  500. uint32_t srcBLen,
  501. q15_t * pDst,
  502. q15_t * pScratch1,
  503. q15_t * pScratch2);
  504. arm_status ref_conv_partial_q15(
  505. q15_t * pSrcA,
  506. uint32_t srcALen,
  507. q15_t * pSrcB,
  508. uint32_t srcBLen,
  509. q15_t * pDst,
  510. uint32_t firstIndex,
  511. uint32_t numPoints);
  512. #define ref_conv_partial_opt_q15(pSrcA, srcALen, pSrcB, srcBLen, pDst, \
  513. firstIndex, numPoints, \
  514. pScratch1, pScratch2) \
  515. ref_conv_partial_q15(pSrcA, srcALen, pSrcB, srcBLen, pDst, \
  516. firstIndex, numPoints)
  517. arm_status ref_conv_partial_fast_q15(
  518. q15_t * pSrcA,
  519. uint32_t srcALen,
  520. q15_t * pSrcB,
  521. uint32_t srcBLen,
  522. q15_t * pDst,
  523. uint32_t firstIndex,
  524. uint32_t numPoints);
  525. arm_status ref_conv_partial_fast_opt_q15(
  526. q15_t * pSrcA,
  527. uint32_t srcALen,
  528. q15_t * pSrcB,
  529. uint32_t srcBLen,
  530. q15_t * pDst,
  531. uint32_t firstIndex,
  532. uint32_t numPoints,
  533. q15_t * pScratch1,
  534. q15_t * pScratch2);
  535. void ref_conv_q7(
  536. q7_t * pSrcA,
  537. uint32_t srcALen,
  538. q7_t * pSrcB,
  539. uint32_t srcBLen,
  540. q7_t * pDst);
  541. #define ref_conv_opt_q7(pSrcA, srcALen, pSrcB, srcBLen, pDst, \
  542. pScratch1, pScratch2) \
  543. ref_conv_q7(pSrcA, srcALen, pSrcB, srcBLen, pDst)
  544. arm_status ref_conv_partial_q7(
  545. q7_t * pSrcA,
  546. uint32_t srcALen,
  547. q7_t * pSrcB,
  548. uint32_t srcBLen,
  549. q7_t * pDst,
  550. uint32_t firstIndex,
  551. uint32_t numPoints);
  552. #define ref_conv_partial_opt_q7(pSrcA, srcALen, pSrcB, srcBLen, pDst, \
  553. firstIndex, numPoints, \
  554. pScratch1, pScratch2) \
  555. ref_conv_partial_q7(pSrcA, srcALen, pSrcB, srcBLen, pDst, \
  556. firstIndex, numPoints)
  557. void ref_correlate_f32(
  558. float32_t * pSrcA,
  559. uint32_t srcALen,
  560. float32_t * pSrcB,
  561. uint32_t srcBLen,
  562. float32_t * pDst);
  563. void ref_correlate_q31(
  564. q31_t * pSrcA,
  565. uint32_t srcALen,
  566. q31_t * pSrcB,
  567. uint32_t srcBLen,
  568. q31_t * pDst);
  569. void ref_correlate_fast_q31(
  570. q31_t * pSrcA,
  571. uint32_t srcALen,
  572. q31_t * pSrcB,
  573. uint32_t srcBLen,
  574. q31_t * pDst);
  575. void ref_correlate_q15(
  576. q15_t * pSrcA,
  577. uint32_t srcALen,
  578. q15_t * pSrcB,
  579. uint32_t srcBLen,
  580. q15_t * pDst);
  581. #define ref_correlate_opt_q15(pSrcA, srcALen, pSrcB, srcBLen, pDst, \
  582. pScratch1) \
  583. ref_correlate_q15(pSrcA, srcALen, pSrcB, srcBLen, pDst)
  584. void ref_correlate_fast_q15(
  585. q15_t * pSrcA,
  586. uint32_t srcALen,
  587. q15_t * pSrcB,
  588. uint32_t srcBLen,
  589. q15_t * pDst);
  590. void ref_correlate_fast_opt_q15(
  591. q15_t * pSrcA,
  592. uint32_t srcALen,
  593. q15_t * pSrcB,
  594. uint32_t srcBLen,
  595. q15_t * pDst,
  596. q15_t * pScratch);
  597. void ref_correlate_q7(
  598. q7_t * pSrcA,
  599. uint32_t srcALen,
  600. q7_t * pSrcB,
  601. uint32_t srcBLen,
  602. q7_t * pDst);
  603. #define ref_correlate_opt_q7(pSrcA, srcALen, pSrcB, srcBLen, pDst, \
  604. pScratch1, pScratch2) \
  605. ref_correlate_q7(pSrcA, srcALen, pSrcB, srcBLen, pDst)
  606. void ref_fir_f32(
  607. const arm_fir_instance_f32 * S,
  608. float32_t * pSrc,
  609. float32_t * pDst,
  610. uint32_t blockSize);
  611. void ref_fir_q31(
  612. const arm_fir_instance_q31 * S,
  613. q31_t * pSrc,
  614. q31_t * pDst,
  615. uint32_t blockSize);
  616. void ref_fir_fast_q31(
  617. const arm_fir_instance_q31 * S,
  618. q31_t * pSrc,
  619. q31_t * pDst,
  620. uint32_t blockSize);
  621. void ref_fir_q15(
  622. const arm_fir_instance_q15 * S,
  623. q15_t * pSrc,
  624. q15_t * pDst,
  625. uint32_t blockSize);
  626. void ref_fir_fast_q15(
  627. const arm_fir_instance_q15 * S,
  628. q15_t * pSrc,
  629. q15_t * pDst,
  630. uint32_t blockSize);
  631. void ref_fir_q7(
  632. const arm_fir_instance_q7 * S,
  633. q7_t * pSrc,
  634. q7_t * pDst,
  635. uint32_t blockSize);
  636. void ref_fir_decimate_f32(
  637. const arm_fir_decimate_instance_f32 * S,
  638. float32_t * pSrc,
  639. float32_t * pDst,
  640. uint32_t blockSize);
  641. void ref_fir_decimate_q31(
  642. const arm_fir_decimate_instance_q31 * S,
  643. q31_t * pSrc,
  644. q31_t * pDst,
  645. uint32_t blockSize);
  646. void ref_fir_decimate_fast_q31(
  647. const arm_fir_decimate_instance_q31 * S,
  648. q31_t * pSrc,
  649. q31_t * pDst,
  650. uint32_t blockSize);
  651. void ref_fir_decimate_q15(
  652. const arm_fir_decimate_instance_q15 * S,
  653. q15_t * pSrc,
  654. q15_t * pDst,
  655. uint32_t blockSize);
  656. void ref_fir_decimate_fast_q15(
  657. const arm_fir_decimate_instance_q15 * S,
  658. q15_t * pSrc,
  659. q15_t * pDst,
  660. uint32_t blockSize);
  661. void ref_fir_lattice_f32(
  662. const arm_fir_lattice_instance_f32 * S,
  663. float32_t * pSrc,
  664. float32_t * pDst,
  665. uint32_t blockSize);
  666. void ref_fir_lattice_q31(
  667. const arm_fir_lattice_instance_q31 * S,
  668. q31_t * pSrc,
  669. q31_t * pDst,
  670. uint32_t blockSize);
  671. void ref_fir_lattice_q15(
  672. const arm_fir_lattice_instance_q15 * S,
  673. q15_t * pSrc,
  674. q15_t * pDst,
  675. uint32_t blockSize);
  676. void ref_fir_sparse_f32(
  677. arm_fir_sparse_instance_f32 * S,
  678. float32_t * pSrc,
  679. float32_t * pDst,
  680. float32_t * pScratchIn,
  681. uint32_t blockSize);
  682. void ref_fir_sparse_q31(
  683. arm_fir_sparse_instance_q31 * S,
  684. q31_t * pSrc,
  685. q31_t * pDst,
  686. q31_t * pScratchIn,
  687. uint32_t blockSize);
  688. void ref_fir_sparse_q15(
  689. arm_fir_sparse_instance_q15 * S,
  690. q15_t * pSrc,
  691. q15_t * pDst,
  692. q15_t * pScratchIn,
  693. q31_t * pScratchOut,
  694. uint32_t blockSize);
  695. void ref_fir_sparse_q7(
  696. arm_fir_sparse_instance_q7 * S,
  697. q7_t *pSrc,
  698. q7_t *pDst,
  699. q7_t *pScratchIn,
  700. q31_t * pScratchOut,
  701. uint32_t blockSize);
  702. void ref_iir_lattice_f32(
  703. const arm_iir_lattice_instance_f32 * S,
  704. float32_t * pSrc,
  705. float32_t * pDst,
  706. uint32_t blockSize);
  707. void ref_iir_lattice_q31(
  708. const arm_iir_lattice_instance_q31 * S,
  709. q31_t * pSrc,
  710. q31_t * pDst,
  711. uint32_t blockSize);
  712. void ref_iir_lattice_q15(
  713. const arm_iir_lattice_instance_q15 * S,
  714. q15_t * pSrc,
  715. q15_t * pDst,
  716. uint32_t blockSize);
  717. void ref_lms_f32(
  718. const arm_lms_instance_f32 * S,
  719. float32_t * pSrc,
  720. float32_t * pRef,
  721. float32_t * pOut,
  722. float32_t * pErr,
  723. uint32_t blockSize);
  724. void ref_lms_norm_f32(
  725. arm_lms_norm_instance_f32 * S,
  726. float32_t * pSrc,
  727. float32_t * pRef,
  728. float32_t * pOut,
  729. float32_t * pErr,
  730. uint32_t blockSize);
  731. void ref_lms_q31(
  732. const arm_lms_instance_q31 * S,
  733. q31_t * pSrc,
  734. q31_t * pRef,
  735. q31_t * pOut,
  736. q31_t * pErr,
  737. uint32_t blockSize);
  738. void ref_lms_norm_q31(
  739. arm_lms_norm_instance_q31 * S,
  740. q31_t * pSrc,
  741. q31_t * pRef,
  742. q31_t * pOut,
  743. q31_t * pErr,
  744. uint32_t blockSize);
  745. void ref_lms_q15(
  746. const arm_lms_instance_q15 * S,
  747. q15_t * pSrc,
  748. q15_t * pRef,
  749. q15_t * pOut,
  750. q15_t * pErr,
  751. uint32_t blockSize);
  752. void ref_lms_norm_q15(
  753. arm_lms_norm_instance_q15 * S,
  754. q15_t * pSrc,
  755. q15_t * pRef,
  756. q15_t * pOut,
  757. q15_t * pErr,
  758. uint32_t blockSize);
  759. void ref_fir_interpolate_f32(
  760. const arm_fir_interpolate_instance_f32 * S,
  761. float32_t * pSrc,
  762. float32_t * pDst,
  763. uint32_t blockSize);
  764. void ref_fir_interpolate_q31(
  765. const arm_fir_interpolate_instance_q31 * S,
  766. q31_t * pSrc,
  767. q31_t * pDst,
  768. uint32_t blockSize);
  769. void ref_fir_interpolate_q15(
  770. const arm_fir_interpolate_instance_q15 * S,
  771. q15_t * pSrc,
  772. q15_t * pDst,
  773. uint32_t blockSize);
  774. /*
  775. * Matrix Functions
  776. */
  777. arm_status ref_mat_cmplx_mult_f32(
  778. const arm_matrix_instance_f32 * pSrcA,
  779. const arm_matrix_instance_f32 * pSrcB,
  780. arm_matrix_instance_f32 * pDst);
  781. arm_status ref_mat_cmplx_mult_q31(
  782. const arm_matrix_instance_q31 * pSrcA,
  783. const arm_matrix_instance_q31 * pSrcB,
  784. arm_matrix_instance_q31 * pDst);
  785. arm_status ref_mat_cmplx_mult_q15(
  786. const arm_matrix_instance_q15 * pSrcA,
  787. const arm_matrix_instance_q15 * pSrcB,
  788. arm_matrix_instance_q15 * pDst);
  789. arm_status ref_mat_inverse_f32(
  790. const arm_matrix_instance_f32 * pSrc,
  791. arm_matrix_instance_f32 * pDst);
  792. arm_status ref_mat_inverse_f64(
  793. const arm_matrix_instance_f64 * pSrc,
  794. arm_matrix_instance_f64 * pDst);
  795. arm_status ref_mat_mult_f32(
  796. const arm_matrix_instance_f32 * pSrcA,
  797. const arm_matrix_instance_f32 * pSrcB,
  798. arm_matrix_instance_f32 * pDst);
  799. arm_status ref_mat_mult_q31(
  800. const arm_matrix_instance_q31 * pSrcA,
  801. const arm_matrix_instance_q31 * pSrcB,
  802. arm_matrix_instance_q31 * pDst);
  803. /* Alias for testing purposes*/
  804. #define ref_mat_mult_fast_q31 ref_mat_mult_q31
  805. arm_status ref_mat_mult_q15(
  806. const arm_matrix_instance_q15 * pSrcA,
  807. const arm_matrix_instance_q15 * pSrcB,
  808. arm_matrix_instance_q15 * pDst);
  809. /* Alias for testing purposes*/
  810. #define ref_mat_mult_fast_q15 ref_mat_mult_q15
  811. arm_status ref_mat_scale_f32(
  812. const arm_matrix_instance_f32 * pSrc,
  813. float32_t scale,
  814. arm_matrix_instance_f32 * pDst);
  815. arm_status ref_mat_scale_q31(
  816. const arm_matrix_instance_q31 * pSrc,
  817. q31_t scale,
  818. int32_t shift,
  819. arm_matrix_instance_q31 * pDst);
  820. arm_status ref_mat_scale_q15(
  821. const arm_matrix_instance_q15 * pSrc,
  822. q15_t scale,
  823. int32_t shift,
  824. arm_matrix_instance_q15 * pDst);
  825. arm_status ref_mat_sub_f32(
  826. const arm_matrix_instance_f32 * pSrcA,
  827. const arm_matrix_instance_f32 * pSrcB,
  828. arm_matrix_instance_f32 * pDst);
  829. arm_status ref_mat_sub_q31(
  830. const arm_matrix_instance_q31 * pSrcA,
  831. const arm_matrix_instance_q31 * pSrcB,
  832. arm_matrix_instance_q31 * pDst);
  833. arm_status ref_mat_sub_q15(
  834. const arm_matrix_instance_q15 * pSrcA,
  835. const arm_matrix_instance_q15 * pSrcB,
  836. arm_matrix_instance_q15 * pDst);
  837. arm_status ref_mat_trans_f64(
  838. const arm_matrix_instance_f64 * pSrc,
  839. arm_matrix_instance_f64 * pDst);
  840. arm_status ref_mat_trans_f32(
  841. const arm_matrix_instance_f32 * pSrc,
  842. arm_matrix_instance_f32 * pDst);
  843. arm_status ref_mat_trans_q31(
  844. const arm_matrix_instance_q31 * pSrc,
  845. arm_matrix_instance_q31 * pDst);
  846. arm_status ref_mat_trans_q15(
  847. const arm_matrix_instance_q15 * pSrc,
  848. arm_matrix_instance_q15 * pDst);
  849. arm_status ref_mat_add_f32(
  850. const arm_matrix_instance_f32 * pSrcA,
  851. const arm_matrix_instance_f32 * pSrcB,
  852. arm_matrix_instance_f32 * pDst);
  853. arm_status ref_mat_add_q31(
  854. const arm_matrix_instance_q31 * pSrcA,
  855. const arm_matrix_instance_q31 * pSrcB,
  856. arm_matrix_instance_q31 * pDst);
  857. arm_status ref_mat_add_q15(
  858. const arm_matrix_instance_q15 * pSrcA,
  859. const arm_matrix_instance_q15 * pSrcB,
  860. arm_matrix_instance_q15 * pDst);
  861. /*
  862. * Statistics Functions
  863. */
  864. void ref_max_f32(
  865. float32_t * pSrc,
  866. uint32_t blockSize,
  867. float32_t * pResult,
  868. uint32_t * pIndex);
  869. void ref_max_q31(
  870. q31_t * pSrc,
  871. uint32_t blockSize,
  872. q31_t * pResult,
  873. uint32_t * pIndex);
  874. void ref_max_q15(
  875. q15_t * pSrc,
  876. uint32_t blockSize,
  877. q15_t * pResult,
  878. uint32_t * pIndex);
  879. void ref_max_q7(
  880. q7_t * pSrc,
  881. uint32_t blockSize,
  882. q7_t * pResult,
  883. uint32_t * pIndex);
  884. void ref_mean_f32(
  885. float32_t * pSrc,
  886. uint32_t blockSize,
  887. float32_t * pResult);
  888. void ref_mean_q31(
  889. q31_t * pSrc,
  890. uint32_t blockSize,
  891. q31_t * pResult);
  892. void ref_mean_q15(
  893. q15_t * pSrc,
  894. uint32_t blockSize,
  895. q15_t * pResult);
  896. void ref_mean_q7(
  897. q7_t * pSrc,
  898. uint32_t blockSize,
  899. q7_t * pResult);
  900. void ref_min_f32(
  901. float32_t * pSrc,
  902. uint32_t blockSize,
  903. float32_t * pResult,
  904. uint32_t * pIndex);
  905. void ref_min_q31(
  906. q31_t * pSrc,
  907. uint32_t blockSize,
  908. q31_t * pResult,
  909. uint32_t * pIndex);
  910. void ref_min_q15(
  911. q15_t * pSrc,
  912. uint32_t blockSize,
  913. q15_t * pResult,
  914. uint32_t * pIndex);
  915. void ref_min_q7(
  916. q7_t * pSrc,
  917. uint32_t blockSize,
  918. q7_t * pResult,
  919. uint32_t * pIndex);
  920. void ref_power_f32(
  921. float32_t * pSrc,
  922. uint32_t blockSize,
  923. float32_t * pResult);
  924. void ref_power_q31(
  925. q31_t * pSrc,
  926. uint32_t blockSize,
  927. q63_t * pResult);
  928. void ref_power_q15(
  929. q15_t * pSrc,
  930. uint32_t blockSize,
  931. q63_t * pResult);
  932. void ref_power_q7(
  933. q7_t * pSrc,
  934. uint32_t blockSize,
  935. q31_t * pResult);
  936. void ref_rms_f32(
  937. float32_t * pSrc,
  938. uint32_t blockSize,
  939. float32_t * pResult);
  940. void ref_rms_q31(
  941. q31_t * pSrc,
  942. uint32_t blockSize,
  943. q31_t * pResult);
  944. void ref_rms_q15(
  945. q15_t * pSrc,
  946. uint32_t blockSize,
  947. q15_t * pResult);
  948. void ref_std_f32(
  949. float32_t * pSrc,
  950. uint32_t blockSize,
  951. float32_t * pResult);
  952. void ref_std_q31(
  953. q31_t * pSrc,
  954. uint32_t blockSize,
  955. q31_t * pResult);
  956. void ref_std_q15(
  957. q15_t * pSrc,
  958. uint32_t blockSize,
  959. q15_t * pResult);
  960. void ref_var_f32(
  961. float32_t * pSrc,
  962. uint32_t blockSize,
  963. float32_t * pResult);
  964. void ref_var_q31(
  965. q31_t * pSrc,
  966. uint32_t blockSize,
  967. q31_t * pResult);
  968. void ref_var_q15(
  969. q15_t * pSrc,
  970. uint32_t blockSize,
  971. q15_t * pResult);
  972. /*
  973. * Support Functions
  974. */
  975. void ref_copy_f32(
  976. float32_t * pSrc,
  977. float32_t * pDst,
  978. uint32_t blockSize);
  979. void ref_copy_q31(
  980. q31_t * pSrc,
  981. q31_t * pDst,
  982. uint32_t blockSize);
  983. void ref_copy_q15(
  984. q15_t * pSrc,
  985. q15_t * pDst,
  986. uint32_t blockSize);
  987. void ref_copy_q7(
  988. q7_t * pSrc,
  989. q7_t * pDst,
  990. uint32_t blockSize);
  991. void ref_fill_f32(
  992. float32_t value,
  993. float32_t * pDst,
  994. uint32_t blockSize);
  995. void ref_fill_q31(
  996. q31_t value,
  997. q31_t * pDst,
  998. uint32_t blockSize);
  999. void ref_fill_q15(
  1000. q15_t value,
  1001. q15_t * pDst,
  1002. uint32_t blockSize);
  1003. void ref_fill_q7(
  1004. q7_t value,
  1005. q7_t * pDst,
  1006. uint32_t blockSize);
  1007. void ref_q31_to_q15(
  1008. q31_t * pSrc,
  1009. q15_t * pDst,
  1010. uint32_t blockSize);
  1011. void ref_q31_to_q7(
  1012. q31_t * pSrc,
  1013. q7_t * pDst,
  1014. uint32_t blockSize);
  1015. void ref_q15_to_q31(
  1016. q15_t * pSrc,
  1017. q31_t * pDst,
  1018. uint32_t blockSize);
  1019. void ref_q15_to_q7(
  1020. q15_t * pSrc,
  1021. q7_t * pDst,
  1022. uint32_t blockSize);
  1023. void ref_q7_to_q31(
  1024. q7_t * pSrc,
  1025. q31_t * pDst,
  1026. uint32_t blockSize);
  1027. void ref_q7_to_q15(
  1028. q7_t * pSrc,
  1029. q15_t * pDst,
  1030. uint32_t blockSize);
  1031. void ref_q63_to_float(
  1032. q63_t * pSrc,
  1033. float32_t * pDst,
  1034. uint32_t blockSize);
  1035. void ref_q31_to_float(
  1036. q31_t * pSrc,
  1037. float32_t * pDst,
  1038. uint32_t blockSize);
  1039. void ref_q15_to_float(
  1040. q15_t * pSrc,
  1041. float32_t * pDst,
  1042. uint32_t blockSize);
  1043. void ref_q7_to_float(
  1044. q7_t * pSrc,
  1045. float32_t * pDst,
  1046. uint32_t blockSize);
  1047. void ref_float_to_q31(
  1048. float32_t * pSrc,
  1049. q31_t * pDst,
  1050. uint32_t blockSize);
  1051. void ref_float_to_q15(
  1052. float32_t * pSrc,
  1053. q15_t * pDst,
  1054. uint32_t blockSize);
  1055. void ref_float_to_q7(
  1056. float32_t * pSrc,
  1057. q7_t * pDst,
  1058. uint32_t blockSize);
  1059. /*
  1060. * Transform Functions
  1061. */
  1062. void ref_cfft_f32(
  1063. const arm_cfft_instance_f32 * S,
  1064. float32_t * p1,
  1065. uint8_t ifftFlag,
  1066. uint8_t bitReverseFlag);
  1067. void ref_cfft_q31(
  1068. const arm_cfft_instance_q31 * S,
  1069. q31_t * p1,
  1070. uint8_t ifftFlag,
  1071. uint8_t bitReverseFlag);
  1072. void ref_cfft_q15(
  1073. const arm_cfft_instance_q15 * S,
  1074. q15_t * p1,
  1075. uint8_t ifftFlag,
  1076. uint8_t bitReverseFlag);
  1077. void ref_cfft_radix2_f32(
  1078. const arm_cfft_radix2_instance_f32 * S,
  1079. float32_t * pSrc);
  1080. void ref_cfft_radix2_q31(
  1081. const arm_cfft_radix2_instance_q31 * S,
  1082. q31_t * pSrc);
  1083. void ref_cfft_radix2_q15(
  1084. const arm_cfft_radix2_instance_q15 * S,
  1085. q15_t * pSrc);
  1086. void ref_cfft_radix4_f32(
  1087. const arm_cfft_radix4_instance_f32 * S,
  1088. float32_t * pSrc);
  1089. void ref_cfft_radix4_q31(
  1090. const arm_cfft_radix4_instance_q31 * S,
  1091. q31_t * pSrc);
  1092. void ref_cfft_radix4_q15(
  1093. const arm_cfft_radix4_instance_q15 * S,
  1094. q15_t * pSrc);
  1095. void ref_rfft_f32(
  1096. arm_rfft_instance_f32 * S,
  1097. float32_t * pSrc,
  1098. float32_t * pDst);
  1099. void ref_rfft_fast_f32(
  1100. arm_rfft_fast_instance_f32 * S,
  1101. float32_t * p, float32_t * pOut,
  1102. uint8_t ifftFlag);
  1103. void ref_rfft_q31(
  1104. const arm_rfft_instance_q31 * S,
  1105. q31_t * pSrc,
  1106. q31_t * pDst);
  1107. void ref_rfft_q15(
  1108. const arm_rfft_instance_q15 * S,
  1109. q15_t * pSrc,
  1110. q15_t * pDst);
  1111. void ref_dct4_f32(
  1112. const arm_dct4_instance_f32 * S,
  1113. float32_t * pState,
  1114. float32_t * pInlineBuffer);
  1115. void ref_dct4_q31(
  1116. const arm_dct4_instance_q31 * S,
  1117. q31_t * pState,
  1118. q31_t * pInlineBuffer);
  1119. void ref_dct4_q15(
  1120. const arm_dct4_instance_q15 * S,
  1121. q15_t * pState,
  1122. q15_t * pInlineBuffer);
  1123. /*
  1124. * Intrinsics
  1125. */
  1126. q31_t ref__QADD8(q31_t x, q31_t y);
  1127. q31_t ref__QSUB8(q31_t x, q31_t y);
  1128. q31_t ref__QADD16(q31_t x, q31_t y);
  1129. q31_t ref__SHADD16(q31_t x, q31_t y);
  1130. q31_t ref__QSUB16(q31_t x, q31_t y);
  1131. q31_t ref__SHSUB16(q31_t x, q31_t y);
  1132. q31_t ref__QASX(q31_t x, q31_t y);
  1133. q31_t ref__SHASX(q31_t x, q31_t y);
  1134. q31_t ref__QSAX(q31_t x, q31_t y);
  1135. q31_t ref__SHSAX(q31_t x, q31_t y);
  1136. q31_t ref__SMUSDX(q31_t x, q31_t y);
  1137. q31_t ref__SMUADX(q31_t x, q31_t y);
  1138. q31_t ref__QADD(q31_t x, q31_t y);
  1139. q31_t ref__QSUB(q31_t x, q31_t y);
  1140. q31_t ref__SMLAD(q31_t x, q31_t y, q31_t sum);
  1141. q31_t ref__SMLADX(q31_t x, q31_t y, q31_t sum);
  1142. q31_t ref__SMLSDX(q31_t x, q31_t y, q31_t sum);
  1143. q63_t ref__SMLALD(q31_t x, q31_t y, q63_t sum);
  1144. q63_t ref__SMLALDX(q31_t x, q31_t y, q63_t sum);
  1145. q31_t ref__SMUAD(q31_t x, q31_t y);
  1146. q31_t ref__SMUSD(q31_t x, q31_t y);
  1147. q31_t ref__SXTB16(q31_t x);
  1148. #ifdef __cplusplus
  1149. }
  1150. #endif
  1151. #endif