FPGA.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: FPGA.cpp
  4. * Description: FPGA
  5. *
  6. * IO implementation for constrained platforms where
  7. * inputs are contained in a header files and output is
  8. * only stdout.
  9. *
  10. * $Date: 20. June 2019
  11. * $Revision: V1.0.0
  12. *
  13. * Target Processor: Cortex-M cores
  14. * -------------------------------------------------------------------- */
  15. /*
  16. * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
  17. *
  18. * SPDX-License-Identifier: Apache-2.0
  19. *
  20. * Licensed under the Apache License, Version 2.0 (the License); you may
  21. * not use this file except in compliance with the License.
  22. * You may obtain a copy of the License at
  23. *
  24. * www.apache.org/licenses/LICENSE-2.0
  25. *
  26. * Unless required by applicable law or agreed to in writing, software
  27. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  28. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  29. * See the License for the specific language governing permissions and
  30. * limitations under the License.
  31. */
  32. #include "Test.h"
  33. #include <string>
  34. #include <cstddef>
  35. #include "FPGA.h"
  36. #include <cstdio>
  37. #include "Generators.h"
  38. #include "arm_math_types.h"
  39. #include "arm_math_types_f16.h"
  40. using namespace std;
  41. namespace Client
  42. {
  43. struct offsetOrGen
  44. {
  45. int kind;
  46. unsigned long offset;
  47. Testing::param_t *data;
  48. Testing::nbSamples_t nbInputSamples;
  49. Testing::nbSamples_t nbOutputSamples;
  50. int dimensions;
  51. };
  52. FPGA::FPGA(const char *testDesc,const char *patterns)
  53. {
  54. this->m_testDesc=testDesc;
  55. this->m_patterns=patterns;
  56. this->currentDesc=testDesc;
  57. this->path=new std::vector<std::string>();
  58. this->patternOffsets=new std::vector<unsigned long>();
  59. this->patternSizes=new std::vector<unsigned long>();
  60. this->parameterOffsets=new std::vector<struct offsetOrGen>();
  61. this->parameterSizes=new std::vector<unsigned long>();
  62. this->outputNames=new std::vector<std::string>();
  63. }
  64. void FPGA::DeleteParams()
  65. {
  66. for (std::vector<struct offsetOrGen>::iterator it = this->parameterOffsets->begin() ; it != this->parameterOffsets->end(); ++it)
  67. {
  68. if (it->kind==1)
  69. {
  70. if (it->data)
  71. {
  72. free(it->data);
  73. it->data = NULL;
  74. }
  75. }
  76. }
  77. }
  78. FPGA::~FPGA()
  79. {
  80. delete(this->path);
  81. delete(this->patternOffsets);
  82. delete(this->patternSizes);
  83. this->DeleteParams();
  84. delete(this->parameterOffsets);
  85. delete(this->parameterSizes);
  86. delete(this->outputNames);
  87. }
  88. /** Read word 32 from C array
  89. */
  90. void FPGA::read32(unsigned long *r)
  91. {
  92. unsigned char a,b,c,d;
  93. unsigned long v;
  94. a = *this->currentDesc++;
  95. b = *this->currentDesc++;
  96. c = *this->currentDesc++;
  97. d = *this->currentDesc++;
  98. //printf("%d %d %d %d\n",a,b,c,d);
  99. v = a | (b << 8) | (c << 16) | (d << 24);
  100. *r = v;
  101. }
  102. /** Read null terminated C string C array
  103. */
  104. void FPGA::readStr(char *str)
  105. {
  106. char *p = str;
  107. while(*this->currentDesc != 0)
  108. {
  109. *p++ = *this->currentDesc++;
  110. }
  111. *p++ = 0;
  112. this->currentDesc++;
  113. }
  114. void FPGA::readChar(char *c)
  115. {
  116. *c = *this->currentDesc;
  117. this->currentDesc++;
  118. }
  119. /** Get output path from output ID
  120. */
  121. std::string FPGA::getOutputPath(Testing::outputID_t id)
  122. {
  123. char fmt[256];
  124. std::string tmp;
  125. tmp += this->testDir;
  126. sprintf(fmt,"/%s_%ld.txt",(*this->outputNames)[id].c_str(),this->currentId);
  127. tmp += std::string(fmt);
  128. //printf("%s\n",tmp.c_str());
  129. return(tmp);
  130. }
  131. /** Read the number of parameters for all the tests in a suite
  132. Used for benchmarking. Same functions executed with
  133. different initializations controlled by the parameters.
  134. */
  135. Testing::nbParameters_t FPGA::ReadNbParameters()
  136. {
  137. unsigned long nb;
  138. this->read32(&nb);
  139. return(nb);
  140. }
  141. void FPGA::ReadTestIdentification()
  142. {
  143. char tmp[255];
  144. unsigned long kind;
  145. unsigned long theId;
  146. char hasPath;
  147. char hasParamID;
  148. Testing::PatternID_t paramID;
  149. //printf("Read ident\n");
  150. this->read32(&kind);
  151. this->read32(&theId);
  152. this->readChar(&hasParamID);
  153. this->m_hasParam=false;
  154. if (hasParamID == 'y')
  155. {
  156. this->m_hasParam=true;
  157. this->read32(&paramID);
  158. this->currentParam=paramID;
  159. }
  160. this->readChar(&hasPath);
  161. if (hasPath == 'y')
  162. {
  163. this->readStr(tmp);
  164. //printf("-->%s\n",tmp);
  165. currentPath.assign(tmp);
  166. }
  167. this->currentKind=kind;
  168. this->currentId=theId;
  169. switch(kind)
  170. {
  171. case 1:
  172. printf("S: t %s\n","");
  173. break;
  174. case 2:
  175. printf("S: s %ld\n",this->currentId);
  176. break;
  177. case 3:
  178. printf("S: g %ld\n",this->currentId);
  179. break;
  180. default:
  181. printf("S: u%s\n","");
  182. }
  183. //printf("End read ident\n\n");
  184. }
  185. void FPGA::recomputeTestDir()
  186. {
  187. this->testDir = ".";
  188. int start = 1;
  189. std::vector<std::string>::const_iterator iter;
  190. for (iter = this->path->begin(); iter != this->path->end(); ++iter)
  191. {
  192. if (start)
  193. {
  194. this->testDir = *iter;
  195. start =0;
  196. }
  197. else
  198. {
  199. if (!(*iter).empty())
  200. {
  201. this->testDir += "/" + *iter;
  202. }
  203. }
  204. }
  205. }
  206. void FPGA::ReadIdentification()
  207. {
  208. this->ReadTestIdentification();
  209. this->path->push_back(currentPath);
  210. this->recomputeTestDir();
  211. }
  212. /** There is only stdout available for "FPGA".
  213. So status output and data output are interleaved.
  214. Status is starting with "S: "
  215. */
  216. void FPGA::DispStatus(Testing::TestStatus status
  217. ,Testing::errorID_t error
  218. ,unsigned long lineNb
  219. ,Testing::cycles_t cycles)
  220. {
  221. if (status == Testing::kTestFailed)
  222. {
  223. printf("S: %ld %ld %ld 0 N\n",this->currentId,error,lineNb);
  224. }
  225. else
  226. {
  227. #ifdef EXTBENCH
  228. printf("S: %ld 0 0 t Y\n",this->currentId);
  229. #else
  230. printf("S: %ld 0 0 %u Y\n",this->currentId, cycles);
  231. #endif
  232. }
  233. }
  234. void FPGA::DispErrorDetails(const char* details)
  235. {
  236. printf("E: %s\n",details);
  237. }
  238. void FPGA::EndGroup()
  239. {
  240. printf("S: p%s\n","");
  241. this->path->pop_back();
  242. }
  243. /** Read pattern list
  244. Different from semihosting.
  245. We read offset and sizes for the patterns
  246. rather than file names.
  247. */
  248. void FPGA::ReadPatternList()
  249. {
  250. unsigned long offset,nb;
  251. unsigned long nbPatterns;
  252. this->read32(&nbPatterns);
  253. this->patternOffsets->clear();
  254. this->patternSizes->clear();
  255. std::string tmpstr;
  256. for(unsigned long i=0;i<nbPatterns;i++)
  257. {
  258. this->read32(&offset);
  259. this->read32(&nb);
  260. this->patternOffsets->push_back(offset);
  261. this->patternSizes->push_back(nb);
  262. }
  263. }
  264. /** Read parameters list
  265. Different from semihosting.
  266. We read offset and sizes for the parameters
  267. rather than file names.
  268. */
  269. void FPGA::ReadParameterList(Testing::nbParameters_t nbParams)
  270. {
  271. unsigned long offset,nb;
  272. unsigned long nbValues;
  273. char paramKind;
  274. this->read32(&nbValues);
  275. this->DeleteParams();
  276. this->parameterOffsets->clear();
  277. this->parameterSizes->clear();
  278. std::string tmpstr;
  279. for(unsigned long i=0;i<nbValues;i++)
  280. {
  281. this->readChar(&paramKind);
  282. struct offsetOrGen gen;
  283. if (paramKind == 'p')
  284. {
  285. gen.kind=0;
  286. this->read32(&offset);
  287. this->read32(&nb);
  288. gen.offset=offset;
  289. gen.kind=0;
  290. gen.nbInputSamples=nb;
  291. gen.dimensions = nbParams;
  292. }
  293. else
  294. {
  295. unsigned long kind,nbInputSamples,nbOutputSamples,dimensions,sample;
  296. Testing::param_t *p,*current;
  297. // Generator kind
  298. this->read32(&kind);
  299. this->read32(&nbInputSamples);
  300. this->read32(&nbOutputSamples);
  301. this->read32(&dimensions);
  302. p=(Testing::param_t*)malloc(sizeof(Testing::param_t)*(nbInputSamples));
  303. current=p;
  304. for(unsigned long i=0;i < nbInputSamples; i ++)
  305. {
  306. this->read32(&sample);
  307. *current++ = (Testing::param_t)sample;
  308. }
  309. gen.kind=1;
  310. gen.data=p;
  311. gen.nbInputSamples = nbInputSamples;
  312. gen.nbOutputSamples = nbOutputSamples;
  313. gen.dimensions = dimensions;
  314. }
  315. this->parameterOffsets->push_back(gen);
  316. this->parameterSizes->push_back(nb);
  317. }
  318. }
  319. void FPGA::ReadOutputList()
  320. {
  321. char tmp[256];
  322. unsigned long nbOutputs;
  323. this->read32(&nbOutputs);
  324. this->outputNames->clear();
  325. std::string tmpstr;
  326. for(unsigned long i=0;i<nbOutputs;i++)
  327. {
  328. this->readStr(tmp);
  329. tmpstr.assign(tmp);
  330. this->outputNames->push_back(tmpstr);
  331. }
  332. }
  333. unsigned long FPGA::getPatternOffset(Testing::PatternID_t id)
  334. {
  335. return((*this->patternOffsets)[id]);
  336. }
  337. Testing::nbSamples_t FPGA::GetPatternSize(Testing::PatternID_t id)
  338. {
  339. return((Testing::nbSamples_t)((*this->patternSizes)[id]));
  340. }
  341. unsigned long FPGA::getParameterOffset(Testing::PatternID_t id)
  342. {
  343. return((*this->parameterOffsets)[id].offset);
  344. }
  345. struct offsetOrGen FPGA::getParameterDesc(Testing::PatternID_t id)
  346. {
  347. return((*this->parameterOffsets)[id]);
  348. }
  349. void FPGA::DumpParams(std::vector<Testing::param_t>& params)
  350. {
  351. bool begin=true;
  352. printf("b ");
  353. for(std::vector<Testing::param_t>::iterator it = params.begin(); it != params.end(); ++it)
  354. {
  355. if (!begin)
  356. {
  357. printf(",");
  358. }
  359. printf("%d",*it);
  360. begin=false;
  361. }
  362. printf("\n");
  363. }
  364. Testing::param_t* FPGA::ImportParams(Testing::PatternID_t id,Testing::nbParameterEntries_t &nbEntries,Testing::ParameterKind &paramKind)
  365. {
  366. nbEntries=0;
  367. unsigned long offset;
  368. Testing::nbSamples_t len;
  369. struct offsetOrGen gen = this->getParameterDesc(id);
  370. if (gen.kind == 0)
  371. {
  372. offset=gen.offset;
  373. paramKind=Testing::kStaticBuffer;
  374. nbEntries = gen.nbInputSamples / gen.dimensions;
  375. const char *patternStart = this->m_patterns + offset;
  376. return((Testing::param_t*)patternStart);
  377. }
  378. else
  379. {
  380. Testing::param_t* result;
  381. // Output samples is number of parameter line
  382. len=gen.nbOutputSamples * gen.dimensions;
  383. paramKind=Testing::kDynamicBuffer;
  384. result=(Testing::param_t*)malloc(len*sizeof(Testing::param_t));
  385. switch(gen.dimensions)
  386. {
  387. case 1:
  388. generate1(result,gen.data,nbEntries);
  389. break;
  390. case 2:
  391. generate2(result,gen.data,nbEntries);
  392. break;
  393. case 3:
  394. generate3(result,gen.data,nbEntries);
  395. break;
  396. case 4:
  397. generate4(result,gen.data,nbEntries);
  398. break;
  399. default:
  400. generate1(result,gen.data,nbEntries);
  401. break;
  402. }
  403. return(result);
  404. }
  405. }
  406. bool FPGA::hasParam()
  407. {
  408. return(this->m_hasParam);
  409. }
  410. Testing::PatternID_t FPGA::getParamID()
  411. {
  412. return(this->currentParam);
  413. }
  414. void FPGA::ImportPattern_f64(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  415. {
  416. unsigned long offset,i;
  417. offset=this->getPatternOffset(id);
  418. const char *patternStart = this->m_patterns + offset;
  419. const float64_t *src = (const float64_t*)patternStart;
  420. float64_t *dst = (float64_t*)p;
  421. if (dst)
  422. {
  423. for(i=0; i < nb; i++)
  424. {
  425. *dst++ = *src++;
  426. }
  427. }
  428. }
  429. void FPGA::ImportPattern_f32(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  430. {
  431. unsigned long offset,i;
  432. offset=this->getPatternOffset(id);
  433. const char *patternStart = this->m_patterns + offset;
  434. const float32_t *src = (const float32_t*)patternStart;
  435. float32_t *dst = (float32_t*)p;
  436. if (dst)
  437. {
  438. for(i=0; i < nb; i++)
  439. {
  440. *dst++ = *src++;
  441. }
  442. }
  443. }
  444. #if !defined( __CC_ARM ) && defined(ARM_FLOAT16_SUPPORTED)
  445. void FPGA::ImportPattern_f16(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  446. {
  447. unsigned long offset,i;
  448. offset=this->getPatternOffset(id);
  449. const char *patternStart = this->m_patterns + offset;
  450. const float16_t *src = (const float16_t*)patternStart;
  451. float16_t *dst = (float16_t*)p;
  452. if (dst)
  453. {
  454. for(i=0; i < nb; i++)
  455. {
  456. *dst++ = *src++;
  457. }
  458. }
  459. }
  460. #endif
  461. void FPGA::ImportPattern_q63(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  462. {
  463. unsigned long offset,i;
  464. offset=this->getPatternOffset(id);
  465. const char *patternStart = this->m_patterns + offset;
  466. const q63_t *src = (const q63_t*)patternStart;
  467. q63_t *dst = (q63_t*)p;
  468. if (dst)
  469. {
  470. for(i=0; i < nb; i++)
  471. {
  472. *dst++ = *src++;
  473. }
  474. }
  475. }
  476. void FPGA::ImportPattern_q31(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  477. {
  478. unsigned long offset,i;
  479. offset=this->getPatternOffset(id);
  480. const char *patternStart = this->m_patterns + offset;
  481. const q31_t *src = (const q31_t*)patternStart;
  482. q31_t *dst = (q31_t*)p;
  483. if (dst)
  484. {
  485. for(i=0; i < nb; i++)
  486. {
  487. *dst++ = *src++;
  488. }
  489. }
  490. }
  491. void FPGA::ImportPattern_q15(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  492. {
  493. unsigned long offset,i;
  494. offset=this->getPatternOffset(id);
  495. const char *patternStart = this->m_patterns + offset;
  496. const q15_t *src = (const q15_t*)patternStart;
  497. q15_t *dst = (q15_t*)p;
  498. if (dst)
  499. {
  500. for(i=0; i < nb; i++)
  501. {
  502. *dst++ = *src++;
  503. }
  504. }
  505. }
  506. void FPGA::ImportPattern_q7(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  507. {
  508. unsigned long offset,i;
  509. offset=this->getPatternOffset(id);
  510. const char *patternStart = this->m_patterns + offset;
  511. const q7_t *src = (const q7_t*)patternStart;
  512. q7_t *dst = (q7_t*)p;
  513. if (dst)
  514. {
  515. for(i=0; i < nb; i++)
  516. {
  517. *dst++ = *src++;
  518. }
  519. }
  520. }
  521. void FPGA::ImportPattern_u64(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  522. {
  523. unsigned long offset,i;
  524. offset=this->getPatternOffset(id);
  525. const char *patternStart = this->m_patterns + offset;
  526. const uint64_t *src = (const uint64_t*)patternStart;
  527. uint64_t *dst = (uint64_t*)p;
  528. if (dst)
  529. {
  530. for(i=0; i < nb; i++)
  531. {
  532. *dst++ = *src++;
  533. }
  534. }
  535. }
  536. void FPGA::ImportPattern_u32(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  537. {
  538. unsigned long offset,i;
  539. offset=this->getPatternOffset(id);
  540. const char *patternStart = this->m_patterns + offset;
  541. const uint32_t *src = (const uint32_t*)patternStart;
  542. uint32_t *dst = (uint32_t*)p;
  543. if (dst)
  544. {
  545. for(i=0; i < nb; i++)
  546. {
  547. *dst++ = *src++;
  548. }
  549. }
  550. }
  551. void FPGA::ImportPattern_u16(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  552. {
  553. unsigned long offset,i;
  554. offset=this->getPatternOffset(id);
  555. const char *patternStart = this->m_patterns + offset;
  556. const uint16_t *src = (const uint16_t*)patternStart;
  557. uint16_t *dst = (uint16_t*)p;
  558. if (dst)
  559. {
  560. for(i=0; i < nb; i++)
  561. {
  562. *dst++ = *src++;
  563. }
  564. }
  565. }
  566. void FPGA::ImportPattern_u8(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  567. {
  568. unsigned long offset,i;
  569. offset=this->getPatternOffset(id);
  570. const char *patternStart = this->m_patterns + offset;
  571. const uint8_t *src = (const uint8_t*)patternStart;
  572. uint8_t *dst = (uint8_t*)p;
  573. if (dst)
  574. {
  575. for(i=0; i < nb; i++)
  576. {
  577. *dst++ = *src++;
  578. }
  579. }
  580. }
  581. /** Dump patterns.
  582. There is only stdout available for "FPGA".
  583. So status output and data output are interleaved.
  584. Data is starting with "D: "
  585. */
  586. void FPGA::DumpPattern_f64(Testing::outputID_t id,Testing::nbSamples_t nb, float64_t* data)
  587. {
  588. std::string fileName = this->getOutputPath(id);
  589. if (data)
  590. {
  591. printf("D: %s\n",fileName.c_str());
  592. Testing::nbSamples_t i=0;
  593. uint64_t t;
  594. float64_t v;
  595. for(i=0; i < nb; i++)
  596. {
  597. v = data[i];
  598. t = TOINT64(v);
  599. printf("D: 0x%016llx\n",t);
  600. }
  601. printf("D: END\n");
  602. }
  603. }
  604. void FPGA::DumpPattern_f32(Testing::outputID_t id,Testing::nbSamples_t nb, float32_t* data)
  605. {
  606. std::string fileName = this->getOutputPath(id);
  607. if (data)
  608. {
  609. printf("D: %s\n",fileName.c_str());
  610. Testing::nbSamples_t i=0;
  611. uint32_t t;
  612. float32_t v;
  613. for(i=0; i < nb; i++)
  614. {
  615. v = data[i];
  616. t = TOINT32(v);
  617. printf("D: 0x%08x\n",t);
  618. }
  619. printf("D: END\n");
  620. }
  621. }
  622. #if !defined( __CC_ARM ) && defined(ARM_FLOAT16_SUPPORTED)
  623. void FPGA::DumpPattern_f16(Testing::outputID_t id,Testing::nbSamples_t nb, float16_t* data)
  624. {
  625. std::string fileName = this->getOutputPath(id);
  626. if (data)
  627. {
  628. printf("D: %s\n",fileName.c_str());
  629. Testing::nbSamples_t i=0;
  630. uint16_t t;
  631. float16_t v;
  632. for(i=0; i < nb; i++)
  633. {
  634. v = data[i];
  635. t = TOINT16(v);
  636. printf("D: 0x0000%04x\n",t);
  637. }
  638. printf("D: END\n");
  639. }
  640. }
  641. #endif
  642. void FPGA::DumpPattern_q63(Testing::outputID_t id,Testing::nbSamples_t nb, q63_t* data)
  643. {
  644. std::string fileName = this->getOutputPath(id);
  645. if (data)
  646. {
  647. printf("D: %s\n",fileName.c_str());
  648. Testing::nbSamples_t i=0;
  649. uint64_t t;
  650. q63_t v;
  651. for(i=0; i < nb; i++)
  652. {
  653. v = data[i];
  654. t = (uint64_t)v;
  655. printf("D: 0x%016llx\n",t);
  656. }
  657. printf("D: END\n");
  658. }
  659. }
  660. void FPGA::DumpPattern_q31(Testing::outputID_t id,Testing::nbSamples_t nb, q31_t* data)
  661. {
  662. std::string fileName = this->getOutputPath(id);
  663. if (data)
  664. {
  665. printf("D: %s\n",fileName.c_str());
  666. Testing::nbSamples_t i=0;
  667. uint32_t t;
  668. q31_t v;
  669. for(i=0; i < nb; i++)
  670. {
  671. v = data[i];
  672. t = (uint32_t)v;
  673. printf("D: 0x%08x\n",t);
  674. }
  675. printf("D: END\n");
  676. }
  677. }
  678. void FPGA::DumpPattern_q15(Testing::outputID_t id,Testing::nbSamples_t nb, q15_t* data)
  679. {
  680. std::string fileName = this->getOutputPath(id);
  681. if (data)
  682. {
  683. printf("D: %s\n",fileName.c_str());
  684. Testing::nbSamples_t i=0;
  685. uint32_t t;
  686. q15_t v;
  687. for(i=0; i < nb; i++)
  688. {
  689. v = data[i];
  690. t = (uint32_t)v;
  691. printf("D: 0x%08x\n",t);
  692. }
  693. printf("D: END\n");
  694. }
  695. }
  696. void FPGA::DumpPattern_q7(Testing::outputID_t id,Testing::nbSamples_t nb, q7_t* data)
  697. {
  698. std::string fileName = this->getOutputPath(id);
  699. if (data)
  700. {
  701. printf("D: %s\n",fileName.c_str());
  702. Testing::nbSamples_t i=0;
  703. uint32_t t;
  704. q7_t v;
  705. for(i=0; i < nb; i++)
  706. {
  707. v = data[i];
  708. t = (uint32_t)v;
  709. printf("D: 0x%08x\n",t);
  710. }
  711. printf("D: END\n");
  712. }
  713. }
  714. void FPGA::DumpPattern_u64(Testing::outputID_t id,Testing::nbSamples_t nb, uint64_t* data)
  715. {
  716. std::string fileName = this->getOutputPath(id);
  717. if (data)
  718. {
  719. printf("D: %s\n",fileName.c_str());
  720. Testing::nbSamples_t i=0;
  721. uint64_t t;
  722. uint64_t v;
  723. for(i=0; i < nb; i++)
  724. {
  725. v = data[i];
  726. t = (uint64_t)v;
  727. printf("D: 0x%016llx\n",t);
  728. }
  729. printf("D: END\n");
  730. }
  731. }
  732. void FPGA::DumpPattern_u32(Testing::outputID_t id,Testing::nbSamples_t nb, uint32_t* data)
  733. {
  734. std::string fileName = this->getOutputPath(id);
  735. if (data)
  736. {
  737. printf("D: %s\n",fileName.c_str());
  738. Testing::nbSamples_t i=0;
  739. uint32_t t;
  740. uint32_t v;
  741. for(i=0; i < nb; i++)
  742. {
  743. v = data[i];
  744. t = (uint32_t)v;
  745. printf("D: 0x%08x\n",t);
  746. }
  747. printf("D: END\n");
  748. }
  749. }
  750. void FPGA::DumpPattern_u16(Testing::outputID_t id,Testing::nbSamples_t nb, uint16_t* data)
  751. {
  752. std::string fileName = this->getOutputPath(id);
  753. if (data)
  754. {
  755. printf("D: %s\n",fileName.c_str());
  756. Testing::nbSamples_t i=0;
  757. uint32_t t;
  758. uint16_t v;
  759. for(i=0; i < nb; i++)
  760. {
  761. v = data[i];
  762. t = (uint32_t)v;
  763. printf("D: 0x%08x\n",t);
  764. }
  765. printf("D: END\n");
  766. }
  767. }
  768. void FPGA::DumpPattern_u8(Testing::outputID_t id,Testing::nbSamples_t nb, uint8_t* data)
  769. {
  770. std::string fileName = this->getOutputPath(id);
  771. if (data)
  772. {
  773. printf("D: %s\n",fileName.c_str());
  774. Testing::nbSamples_t i=0;
  775. uint32_t t;
  776. uint8_t v;
  777. for(i=0; i < nb; i++)
  778. {
  779. v = data[i];
  780. t = (uint32_t)v;
  781. printf("D: 0x%08x\n",t);
  782. }
  783. printf("D: END\n");
  784. }
  785. }
  786. Testing::testID_t FPGA::CurrentTestID()
  787. {
  788. return(this->currentId);
  789. }
  790. }