FPGA.cpp 22 KB

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