ref.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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