FPGA.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  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 <stdio.h>
  37. #include <string.h>
  38. #include "Generators.h"
  39. namespace Client
  40. {
  41. struct offsetOrGen
  42. {
  43. int kind;
  44. unsigned long offset;
  45. Testing::param_t *data;
  46. Testing::nbSamples_t nbInputSamples;
  47. Testing::nbSamples_t nbOutputSamples;
  48. int dimensions;
  49. };
  50. FPGA::FPGA(const char *testDesc,const char *patterns)
  51. {
  52. this->m_testDesc=testDesc;
  53. this->m_patterns=patterns;
  54. this->currentDesc=testDesc;
  55. this->path=new std::vector<std::string>();
  56. this->patternOffsets=new std::vector<unsigned long>();
  57. this->patternSizes=new std::vector<unsigned long>();
  58. this->parameterOffsets=new std::vector<struct offsetOrGen>();
  59. this->parameterSizes=new std::vector<unsigned long>();
  60. this->outputNames=new std::vector<std::string>();
  61. }
  62. void FPGA::DeleteParams()
  63. {
  64. for (std::vector<struct offsetOrGen>::iterator it = this->parameterOffsets->begin() ; it != this->parameterOffsets->end(); ++it)
  65. {
  66. if (it->kind==1)
  67. {
  68. if (it->data)
  69. {
  70. free(it->data);
  71. it->data = NULL;
  72. }
  73. }
  74. }
  75. }
  76. FPGA::~FPGA()
  77. {
  78. delete(this->path);
  79. delete(this->patternOffsets);
  80. delete(this->patternSizes);
  81. this->DeleteParams();
  82. delete(this->parameterOffsets);
  83. delete(this->parameterSizes);
  84. delete(this->outputNames);
  85. }
  86. /** Read word 64 from C array
  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 \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\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\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(int 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(int 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(int 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(int 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 )
  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_u32(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 uint32_t *src = (const uint32_t*)patternStart;
  527. uint32_t *dst = (uint32_t*)p;
  528. if (dst)
  529. {
  530. for(i=0; i < nb; i++)
  531. {
  532. *dst++ = *src++;
  533. }
  534. }
  535. }
  536. void FPGA::ImportPattern_u16(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 uint16_t *src = (const uint16_t*)patternStart;
  542. uint16_t *dst = (uint16_t*)p;
  543. if (dst)
  544. {
  545. for(i=0; i < nb; i++)
  546. {
  547. *dst++ = *src++;
  548. }
  549. }
  550. }
  551. void FPGA::ImportPattern_u8(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 uint8_t *src = (const uint8_t*)patternStart;
  557. uint8_t *dst = (uint8_t*)p;
  558. if (dst)
  559. {
  560. for(i=0; i < nb; i++)
  561. {
  562. *dst++ = *src++;
  563. }
  564. }
  565. }
  566. /** Dump patterns.
  567. There is only stdout available for "FPGA".
  568. So status output and data output are interleaved.
  569. Data is starting with "D: "
  570. */
  571. void FPGA::DumpPattern_f64(Testing::outputID_t id,Testing::nbSamples_t nb, float64_t* data)
  572. {
  573. std::string fileName = this->getOutputPath(id);
  574. if (data)
  575. {
  576. printf("D: %s\n",fileName.c_str());
  577. Testing::nbSamples_t i=0;
  578. uint64_t t;
  579. float64_t v;
  580. for(i=0; i < nb; i++)
  581. {
  582. v = data[i];
  583. t = TOINT64(v);
  584. printf("D: 0x%016llx\n",t);
  585. }
  586. printf("D: END\n");
  587. }
  588. }
  589. void FPGA::DumpPattern_f32(Testing::outputID_t id,Testing::nbSamples_t nb, float32_t* data)
  590. {
  591. std::string fileName = this->getOutputPath(id);
  592. if (data)
  593. {
  594. printf("D: %s\n",fileName.c_str());
  595. Testing::nbSamples_t i=0;
  596. uint32_t t;
  597. float32_t v;
  598. for(i=0; i < nb; i++)
  599. {
  600. v = data[i];
  601. t = TOINT32(v);
  602. printf("D: 0x%08x\n",t);
  603. }
  604. printf("D: END\n");
  605. }
  606. }
  607. #if !defined( __CC_ARM )
  608. void FPGA::DumpPattern_f16(Testing::outputID_t id,Testing::nbSamples_t nb, float16_t* data)
  609. {
  610. std::string fileName = this->getOutputPath(id);
  611. if (data)
  612. {
  613. printf("D: %s\n",fileName.c_str());
  614. Testing::nbSamples_t i=0;
  615. uint16_t t;
  616. float16_t v;
  617. for(i=0; i < nb; i++)
  618. {
  619. v = data[i];
  620. t = TOINT16(v);
  621. printf("D: 0x0000%04x\n",t);
  622. }
  623. printf("D: END\n");
  624. }
  625. }
  626. #endif
  627. void FPGA::DumpPattern_q63(Testing::outputID_t id,Testing::nbSamples_t nb, q63_t* data)
  628. {
  629. std::string fileName = this->getOutputPath(id);
  630. if (data)
  631. {
  632. printf("D: %s\n",fileName.c_str());
  633. Testing::nbSamples_t i=0;
  634. uint64_t t;
  635. q63_t v;
  636. for(i=0; i < nb; i++)
  637. {
  638. v = data[i];
  639. t = (uint64_t)v;
  640. printf("D: 0x%016llx\n",t);
  641. }
  642. printf("D: END\n");
  643. }
  644. }
  645. void FPGA::DumpPattern_q31(Testing::outputID_t id,Testing::nbSamples_t nb, q31_t* data)
  646. {
  647. std::string fileName = this->getOutputPath(id);
  648. if (data)
  649. {
  650. printf("D: %s\n",fileName.c_str());
  651. Testing::nbSamples_t i=0;
  652. uint32_t t;
  653. q31_t v;
  654. for(i=0; i < nb; i++)
  655. {
  656. v = data[i];
  657. t = (uint32_t)v;
  658. printf("D: 0x%08x\n",t);
  659. }
  660. printf("D: END\n");
  661. }
  662. }
  663. void FPGA::DumpPattern_q15(Testing::outputID_t id,Testing::nbSamples_t nb, q15_t* data)
  664. {
  665. std::string fileName = this->getOutputPath(id);
  666. if (data)
  667. {
  668. printf("D: %s\n",fileName.c_str());
  669. Testing::nbSamples_t i=0;
  670. uint32_t t;
  671. q15_t v;
  672. for(i=0; i < nb; i++)
  673. {
  674. v = data[i];
  675. t = (uint32_t)v;
  676. printf("D: 0x%08x\n",t);
  677. }
  678. printf("D: END\n");
  679. }
  680. }
  681. void FPGA::DumpPattern_q7(Testing::outputID_t id,Testing::nbSamples_t nb, q7_t* data)
  682. {
  683. std::string fileName = this->getOutputPath(id);
  684. if (data)
  685. {
  686. printf("D: %s\n",fileName.c_str());
  687. Testing::nbSamples_t i=0;
  688. uint32_t t;
  689. q7_t v;
  690. for(i=0; i < nb; i++)
  691. {
  692. v = data[i];
  693. t = (uint32_t)v;
  694. printf("D: 0x%08x\n",t);
  695. }
  696. printf("D: END\n");
  697. }
  698. }
  699. void FPGA::DumpPattern_u32(Testing::outputID_t id,Testing::nbSamples_t nb, uint32_t* data)
  700. {
  701. std::string fileName = this->getOutputPath(id);
  702. if (data)
  703. {
  704. printf("D: %s\n",fileName.c_str());
  705. Testing::nbSamples_t i=0;
  706. uint32_t t;
  707. uint32_t v;
  708. for(i=0; i < nb; i++)
  709. {
  710. v = data[i];
  711. t = (uint32_t)v;
  712. printf("D: 0x%08x\n",t);
  713. }
  714. printf("D: END\n");
  715. }
  716. }
  717. void FPGA::DumpPattern_u16(Testing::outputID_t id,Testing::nbSamples_t nb, uint16_t* data)
  718. {
  719. std::string fileName = this->getOutputPath(id);
  720. if (data)
  721. {
  722. printf("D: %s\n",fileName.c_str());
  723. Testing::nbSamples_t i=0;
  724. uint32_t t;
  725. uint16_t v;
  726. for(i=0; i < nb; i++)
  727. {
  728. v = data[i];
  729. t = (uint32_t)v;
  730. printf("D: 0x%08x\n",t);
  731. }
  732. printf("D: END\n");
  733. }
  734. }
  735. void FPGA::DumpPattern_u8(Testing::outputID_t id,Testing::nbSamples_t nb, uint8_t* data)
  736. {
  737. std::string fileName = this->getOutputPath(id);
  738. if (data)
  739. {
  740. printf("D: %s\n",fileName.c_str());
  741. Testing::nbSamples_t i=0;
  742. uint32_t t;
  743. uint8_t v;
  744. for(i=0; i < nb; i++)
  745. {
  746. v = data[i];
  747. t = (uint32_t)v;
  748. printf("D: 0x%08x\n",t);
  749. }
  750. printf("D: END\n");
  751. }
  752. }
  753. Testing::testID_t FPGA::CurrentTestID()
  754. {
  755. return(this->currentId);
  756. }
  757. }