FPGA.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: FPGA.h
  4. * Description: FPGA Header
  5. *
  6. * $Date: 20. June 2019
  7. * $Revision: V1.0.0
  8. *
  9. * Target Processor: Cortex-M cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #ifndef _FPGA_H_
  29. #define _FPGA_H_
  30. #include <string>
  31. #include "stdlib.h"
  32. namespace Client
  33. {
  34. /*
  35. FPGA driver. Used to read a C array describing how to drive the test.
  36. */
  37. struct offsetOrGen;
  38. class FPGA:public IO
  39. {
  40. public:
  41. FPGA(const char *testDesc,const char *patterns);
  42. ~FPGA();
  43. virtual void ReadIdentification();
  44. virtual void ReadTestIdentification();
  45. virtual Testing::nbParameters_t ReadNbParameters();
  46. virtual void DispStatus(Testing::TestStatus,Testing::errorID_t,unsigned long,Testing::cycles_t);
  47. virtual void EndGroup();
  48. virtual void ReadPatternList();
  49. virtual void ReadOutputList();
  50. virtual void ReadParameterList(Testing::nbParameters_t);
  51. virtual Testing::nbSamples_t GetPatternSize(Testing::PatternID_t);
  52. virtual void ImportPattern_f64(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  53. virtual void ImportPattern_f32(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  54. virtual void ImportPattern_q63(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  55. virtual void ImportPattern_q31(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  56. virtual void ImportPattern_q15(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  57. virtual void ImportPattern_q7(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  58. virtual void ImportPattern_u32(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  59. virtual void ImportPattern_u16(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  60. virtual void ImportPattern_u8(Testing::PatternID_t,char*,Testing::nbSamples_t nb);
  61. virtual void DumpParams(std::vector<Testing::param_t>&);
  62. virtual Testing::param_t* ImportParams(Testing::PatternID_t,Testing::nbParameterEntries_t &,Testing::ParameterKind &);
  63. virtual bool hasParam();
  64. virtual Testing::PatternID_t getParamID();
  65. virtual void DumpPattern_f64(Testing::outputID_t,Testing::nbSamples_t nb, float64_t* data);
  66. virtual void DumpPattern_f32(Testing::outputID_t,Testing::nbSamples_t nb, float32_t* data);
  67. virtual void DumpPattern_q63(Testing::outputID_t,Testing::nbSamples_t nb, q63_t* data);
  68. virtual void DumpPattern_q31(Testing::outputID_t,Testing::nbSamples_t nb, q31_t* data);
  69. virtual void DumpPattern_q15(Testing::outputID_t,Testing::nbSamples_t nb, q15_t* data);
  70. virtual void DumpPattern_q7(Testing::outputID_t,Testing::nbSamples_t nb, q7_t* data);
  71. virtual void DumpPattern_u32(Testing::outputID_t,Testing::nbSamples_t nb, uint32_t* data);
  72. virtual void DumpPattern_u16(Testing::outputID_t,Testing::nbSamples_t nb, uint16_t* data);
  73. virtual void DumpPattern_u8(Testing::outputID_t,Testing::nbSamples_t nb, uint8_t* data);
  74. virtual Testing::testID_t CurrentTestID();
  75. private:
  76. void recomputeTestDir();
  77. void DeleteParams();
  78. struct offsetOrGen getParameterDesc(Testing::PatternID_t id);
  79. // Get offset in C array of a pattern.
  80. unsigned long getPatternOffset(Testing::PatternID_t);
  81. // Get output path
  82. std::string getOutputPath(Testing::outputID_t id);
  83. // Get offset in C array of a parameter.
  84. unsigned long getParameterOffset(Testing::PatternID_t);
  85. // Read data from the driver C array.
  86. void read32(unsigned long *);
  87. void readStr(char *str);
  88. void readChar(char *);
  89. // Driver array
  90. const char *m_testDesc;
  91. // Pattern array
  92. const char *m_patterns;
  93. // Parameter array
  94. char *m_parameters;
  95. // Current position in the driver array
  96. const char *currentDesc;
  97. int currentKind;
  98. Testing::testID_t currentId;
  99. // Current param ID for the node
  100. Testing::PatternID_t currentParam;
  101. bool m_hasParam;
  102. // Association pattern ID to pattern offset in C array m_patterns
  103. std::vector<unsigned long> *patternOffsets;
  104. // Association pattern ID to pattern size.
  105. std::vector<Testing::nbSamples_t> *patternSizes;
  106. // Association parameter ID to parameter offset in C array m_parameters
  107. std::vector<struct offsetOrGen> *parameterOffsets;
  108. // Association parameter ID to parameter size.
  109. std::vector<Testing::nbSamples_t> *parameterSizes;
  110. // testDir is only used for output.
  111. // In a future version it will be removed.
  112. // Output will just use ID and post processing
  113. // script will recover the path
  114. std::string testDir;
  115. std::vector<std::string> *path;
  116. std::string currentPath;
  117. std::vector<std::string> *outputNames;
  118. };
  119. }
  120. #endif