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 <cstdlib> 32 #include "arm_math_types.h" 33 #include "arm_math_types_f16.h" 34 35 namespace Client 36 { 37 38 /* 39 40 FPGA driver. Used to read a C array describing how to drive the test. 41 42 43 */ 44 45 struct offsetOrGen; 46 47 class FPGA:public IO 48 { 49 public: 50 FPGA(const char *testDesc,const char *patterns); 51 ~FPGA(); 52 virtual void ReadIdentification(); 53 virtual void ReadTestIdentification(); 54 virtual Testing::nbParameters_t ReadNbParameters(); 55 virtual void DispStatus(Testing::TestStatus,Testing::errorID_t,unsigned long,Testing::cycles_t); 56 virtual void DispErrorDetails(const char* ); 57 virtual void EndGroup(); 58 virtual void ReadPatternList(); 59 virtual void ReadOutputList(); 60 virtual void ReadParameterList(Testing::nbParameters_t); 61 virtual Testing::nbSamples_t GetPatternSize(Testing::PatternID_t); 62 63 virtual void ImportPattern_f64(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 64 virtual void ImportPattern_f32(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 65 #if !defined( __CC_ARM ) && defined(ARM_FLOAT16_SUPPORTED) 66 virtual void ImportPattern_f16(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 67 #endif 68 virtual void ImportPattern_q63(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 69 virtual void ImportPattern_q31(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 70 virtual void ImportPattern_q15(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 71 virtual void ImportPattern_q7(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 72 virtual void ImportPattern_u64(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 73 virtual void ImportPattern_u32(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 74 virtual void ImportPattern_u16(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 75 virtual void ImportPattern_u8(Testing::PatternID_t,char*,Testing::nbSamples_t nb); 76 77 virtual void DumpParams(std::vector<Testing::param_t>&); 78 virtual Testing::param_t* ImportParams(Testing::PatternID_t,Testing::nbParameterEntries_t &,Testing::ParameterKind &); 79 virtual bool hasParam(); 80 virtual Testing::PatternID_t getParamID(); 81 82 virtual void DumpPattern_f64(Testing::outputID_t,Testing::nbSamples_t nb, float64_t* data); 83 virtual void DumpPattern_f32(Testing::outputID_t,Testing::nbSamples_t nb, float32_t* data); 84 #if !defined( __CC_ARM ) && defined(ARM_FLOAT16_SUPPORTED) 85 virtual void DumpPattern_f16(Testing::outputID_t,Testing::nbSamples_t nb, float16_t* data); 86 #endif 87 virtual void DumpPattern_q63(Testing::outputID_t,Testing::nbSamples_t nb, q63_t* data); 88 virtual void DumpPattern_q31(Testing::outputID_t,Testing::nbSamples_t nb, q31_t* data); 89 virtual void DumpPattern_q15(Testing::outputID_t,Testing::nbSamples_t nb, q15_t* data); 90 virtual void DumpPattern_q7(Testing::outputID_t,Testing::nbSamples_t nb, q7_t* data); 91 virtual void DumpPattern_u64(Testing::outputID_t,Testing::nbSamples_t nb, uint64_t* data); 92 virtual void DumpPattern_u32(Testing::outputID_t,Testing::nbSamples_t nb, uint32_t* data); 93 virtual void DumpPattern_u16(Testing::outputID_t,Testing::nbSamples_t nb, uint16_t* data); 94 virtual void DumpPattern_u8(Testing::outputID_t,Testing::nbSamples_t nb, uint8_t* data); 95 96 virtual Testing::testID_t CurrentTestID(); 97 private: 98 void recomputeTestDir(); 99 void DeleteParams(); 100 struct offsetOrGen getParameterDesc(Testing::PatternID_t id); 101 // Get offset in C array of a pattern. 102 unsigned long getPatternOffset(Testing::PatternID_t); 103 // Get output path 104 std::string getOutputPath(Testing::outputID_t id); 105 // Get offset in C array of a parameter. 106 unsigned long getParameterOffset(Testing::PatternID_t); 107 // Read data from the driver C array. 108 void read32(unsigned long *); 109 void readStr(char *str); 110 void readChar(char *); 111 112 // Driver array 113 const char *m_testDesc; 114 115 // Pattern array 116 const char *m_patterns; 117 118 // Parameter array 119 //char *m_parameters; 120 121 // Current position in the driver array 122 const char *currentDesc; 123 int currentKind; 124 Testing::testID_t currentId; 125 // Current param ID for the node 126 Testing::PatternID_t currentParam; 127 bool m_hasParam; 128 129 // Association pattern ID to pattern offset in C array m_patterns 130 std::vector<unsigned long> *patternOffsets; 131 132 // Association pattern ID to pattern size. 133 std::vector<Testing::nbSamples_t> *patternSizes; 134 135 // Association parameter ID to parameter offset in C array m_parameters 136 std::vector<struct offsetOrGen> *parameterOffsets; 137 138 // Association parameter ID to parameter size. 139 std::vector<Testing::nbSamples_t> *parameterSizes; 140 141 // testDir is only used for output. 142 // In a future version it will be removed. 143 // Output will just use ID and post processing 144 // script will recover the path 145 std::string testDir; 146 std::vector<std::string> *path; 147 std::string currentPath; 148 std::vector<std::string> *outputNames; 149 150 }; 151 } 152 153 #endif 154