FPGA.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  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. void FPGA::ImportPattern_q63(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  445. {
  446. unsigned long offset,i;
  447. offset=this->getPatternOffset(id);
  448. const char *patternStart = this->m_patterns + offset;
  449. const q63_t *src = (const q63_t*)patternStart;
  450. q63_t *dst = (q63_t*)p;
  451. if (dst)
  452. {
  453. for(i=0; i < nb; i++)
  454. {
  455. *dst++ = *src++;
  456. }
  457. }
  458. }
  459. void FPGA::ImportPattern_q31(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  460. {
  461. unsigned long offset,i;
  462. offset=this->getPatternOffset(id);
  463. const char *patternStart = this->m_patterns + offset;
  464. const q31_t *src = (const q31_t*)patternStart;
  465. q31_t *dst = (q31_t*)p;
  466. if (dst)
  467. {
  468. for(i=0; i < nb; i++)
  469. {
  470. *dst++ = *src++;
  471. }
  472. }
  473. }
  474. void FPGA::ImportPattern_q15(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  475. {
  476. unsigned long offset,i;
  477. offset=this->getPatternOffset(id);
  478. const char *patternStart = this->m_patterns + offset;
  479. const q15_t *src = (const q15_t*)patternStart;
  480. q15_t *dst = (q15_t*)p;
  481. if (dst)
  482. {
  483. for(i=0; i < nb; i++)
  484. {
  485. *dst++ = *src++;
  486. }
  487. }
  488. }
  489. void FPGA::ImportPattern_q7(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  490. {
  491. unsigned long offset,i;
  492. offset=this->getPatternOffset(id);
  493. const char *patternStart = this->m_patterns + offset;
  494. const q7_t *src = (const q7_t*)patternStart;
  495. q7_t *dst = (q7_t*)p;
  496. if (dst)
  497. {
  498. for(i=0; i < nb; i++)
  499. {
  500. *dst++ = *src++;
  501. }
  502. }
  503. }
  504. void FPGA::ImportPattern_u32(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  505. {
  506. unsigned long offset,i;
  507. offset=this->getPatternOffset(id);
  508. const char *patternStart = this->m_patterns + offset;
  509. const uint32_t *src = (const uint32_t*)patternStart;
  510. uint32_t *dst = (uint32_t*)p;
  511. if (dst)
  512. {
  513. for(i=0; i < nb; i++)
  514. {
  515. *dst++ = *src++;
  516. }
  517. }
  518. }
  519. void FPGA::ImportPattern_u16(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  520. {
  521. unsigned long offset,i;
  522. offset=this->getPatternOffset(id);
  523. const char *patternStart = this->m_patterns + offset;
  524. const uint16_t *src = (const uint16_t*)patternStart;
  525. uint16_t *dst = (uint16_t*)p;
  526. if (dst)
  527. {
  528. for(i=0; i < nb; i++)
  529. {
  530. *dst++ = *src++;
  531. }
  532. }
  533. }
  534. void FPGA::ImportPattern_u8(Testing::PatternID_t id,char* p,Testing::nbSamples_t nb)
  535. {
  536. unsigned long offset,i;
  537. offset=this->getPatternOffset(id);
  538. const char *patternStart = this->m_patterns + offset;
  539. const uint8_t *src = (const uint8_t*)patternStart;
  540. uint8_t *dst = (uint8_t*)p;
  541. if (dst)
  542. {
  543. for(i=0; i < nb; i++)
  544. {
  545. *dst++ = *src++;
  546. }
  547. }
  548. }
  549. /** Dump patterns.
  550. There is only stdout available for "FPGA".
  551. So status output and data output are interleaved.
  552. Data is starting with "D: "
  553. */
  554. void FPGA::DumpPattern_f64(Testing::outputID_t id,Testing::nbSamples_t nb, float64_t* data)
  555. {
  556. std::string fileName = this->getOutputPath(id);
  557. if (data)
  558. {
  559. printf("D: %s\n",fileName.c_str());
  560. Testing::nbSamples_t i=0;
  561. uint64_t t;
  562. float64_t v;
  563. for(i=0; i < nb; i++)
  564. {
  565. v = data[i];
  566. t = TOINT64(v);
  567. printf("D: 0x%016llx\n",t);
  568. }
  569. printf("D: END\n");
  570. }
  571. }
  572. void FPGA::DumpPattern_f32(Testing::outputID_t id,Testing::nbSamples_t nb, float32_t* data)
  573. {
  574. std::string fileName = this->getOutputPath(id);
  575. if (data)
  576. {
  577. printf("D: %s\n",fileName.c_str());
  578. Testing::nbSamples_t i=0;
  579. uint32_t t;
  580. float32_t v;
  581. for(i=0; i < nb; i++)
  582. {
  583. v = data[i];
  584. t = TOINT32(v);
  585. printf("D: 0x%08x\n",t);
  586. }
  587. printf("D: END\n");
  588. }
  589. }
  590. void FPGA::DumpPattern_q63(Testing::outputID_t id,Testing::nbSamples_t nb, q63_t* data)
  591. {
  592. std::string fileName = this->getOutputPath(id);
  593. if (data)
  594. {
  595. printf("D: %s\n",fileName.c_str());
  596. Testing::nbSamples_t i=0;
  597. uint64_t t;
  598. q63_t v;
  599. for(i=0; i < nb; i++)
  600. {
  601. v = data[i];
  602. t = (uint64_t)v;
  603. printf("D: 0x%016llx\n",t);
  604. }
  605. printf("D: END\n");
  606. }
  607. }
  608. void FPGA::DumpPattern_q31(Testing::outputID_t id,Testing::nbSamples_t nb, q31_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. uint32_t t;
  616. q31_t v;
  617. for(i=0; i < nb; i++)
  618. {
  619. v = data[i];
  620. t = (uint32_t)v;
  621. printf("D: 0x%08x\n",t);
  622. }
  623. printf("D: END\n");
  624. }
  625. }
  626. void FPGA::DumpPattern_q15(Testing::outputID_t id,Testing::nbSamples_t nb, q15_t* data)
  627. {
  628. std::string fileName = this->getOutputPath(id);
  629. if (data)
  630. {
  631. printf("D: %s\n",fileName.c_str());
  632. Testing::nbSamples_t i=0;
  633. uint32_t t;
  634. q15_t v;
  635. for(i=0; i < nb; i++)
  636. {
  637. v = data[i];
  638. t = (uint32_t)v;
  639. printf("D: 0x%08x\n",t);
  640. }
  641. printf("D: END\n");
  642. }
  643. }
  644. void FPGA::DumpPattern_q7(Testing::outputID_t id,Testing::nbSamples_t nb, q7_t* data)
  645. {
  646. std::string fileName = this->getOutputPath(id);
  647. if (data)
  648. {
  649. printf("D: %s\n",fileName.c_str());
  650. Testing::nbSamples_t i=0;
  651. uint32_t t;
  652. q7_t v;
  653. for(i=0; i < nb; i++)
  654. {
  655. v = data[i];
  656. t = (uint32_t)v;
  657. printf("D: 0x%08x\n",t);
  658. }
  659. printf("D: END\n");
  660. }
  661. }
  662. void FPGA::DumpPattern_u32(Testing::outputID_t id,Testing::nbSamples_t nb, uint32_t* data)
  663. {
  664. std::string fileName = this->getOutputPath(id);
  665. if (data)
  666. {
  667. printf("D: %s\n",fileName.c_str());
  668. Testing::nbSamples_t i=0;
  669. uint32_t t;
  670. uint32_t v;
  671. for(i=0; i < nb; i++)
  672. {
  673. v = data[i];
  674. t = (uint32_t)v;
  675. printf("D: 0x%08x\n",t);
  676. }
  677. printf("D: END\n");
  678. }
  679. }
  680. void FPGA::DumpPattern_u16(Testing::outputID_t id,Testing::nbSamples_t nb, uint16_t* data)
  681. {
  682. std::string fileName = this->getOutputPath(id);
  683. if (data)
  684. {
  685. printf("D: %s\n",fileName.c_str());
  686. Testing::nbSamples_t i=0;
  687. uint32_t t;
  688. uint16_t v;
  689. for(i=0; i < nb; i++)
  690. {
  691. v = data[i];
  692. t = (uint32_t)v;
  693. printf("D: 0x%08x\n",t);
  694. }
  695. printf("D: END\n");
  696. }
  697. }
  698. void FPGA::DumpPattern_u8(Testing::outputID_t id,Testing::nbSamples_t nb, uint8_t* data)
  699. {
  700. std::string fileName = this->getOutputPath(id);
  701. if (data)
  702. {
  703. printf("D: %s\n",fileName.c_str());
  704. Testing::nbSamples_t i=0;
  705. uint32_t t;
  706. uint8_t v;
  707. for(i=0; i < nb; i++)
  708. {
  709. v = data[i];
  710. t = (uint32_t)v;
  711. printf("D: 0x%08x\n",t);
  712. }
  713. printf("D: END\n");
  714. }
  715. }
  716. Testing::testID_t FPGA::CurrentTestID()
  717. {
  718. return(this->currentId);
  719. }
  720. }