cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
SimNtsUtils.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 -- 2021 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
31 #ifndef _SIM_NTS_UTILS_H_
32 #define _SIM_NTS_UTILS_H_
33 
34 #include <stdlib.h>
35 #include <unistd.h>
36 #include <iostream>
37 #include <fstream>
38 
39 #include "../MEM/mem.hpp"
40 #include "../NTS/nts.hpp"
41 #include "../NTS/nts_utils.hpp"
42 #include "../NTS/SimNtsUtils.hpp"
43 
44 using namespace std;
45 
46 
50 
56 
59 #ifndef __SYNTHESIS__
60  bool isDatFile (string fileName);
61  bool isDottedDecimal (string ipStr);
62  bool isHexString (string str);
63  ap_uint<32> myDottedDecimalIpToUint32(string ipStr);
64  vector<string> myTokenizer (string strBuff, char delimiter);
65  string myUint64ToStrHex(ap_uint<64> inputNumber);
66  string myUint8ToStrHex (ap_uint<8> inputNumber);
67  ap_uint<64> myStrHexToUint64(string dataString);
68  ap_uint<8> myStrHexToUint8 (string keepString);
69  int myDiffTwoFiles (string dataFileName, string goldFileName);
70 #endif
71 
72 
75 #ifndef __SYNTHESIS__
76  bool readAxisRawFromLine (AxisRaw &axiRaw, string stringBuffer);
77  bool readFpgaSocketFromLine (SockAddr &hostSock, string stringBuffer);
78  bool readFpgaSndPortFromLine(Ly4Port &port, string stringBuffer);
79  bool readHostSocketFromLine (SockAddr &hostSock, string stringBuffer);
80 #endif
81 
82 
85 #ifndef __SYNTHESIS__
86  bool readAxisRawFromFile (AxisRaw &axisRaw, ifstream &inpFileStream);
87  bool readTbParamFromFile (const string paramName, const string datFile,
88  unsigned int &paramVal);
89  int writeAxisAppToFile (AxisApp &axisApp, ofstream &outFileStream);
90  int writeAxisAppToFile (AxisApp &axisApp, ofstream &outFileStream, int &wrCount);
91  bool writeAxisRawToFile (AxisRaw &axisRaw, ofstream &outFileStream);
92  bool writeSocketPairToFile(SocketPair &socketPair, ofstream &outFileStream);
93  template <int D> \
94  bool writeApUintToFile (ap_uint<D> &data, ofstream &outFileStream);
95 #endif
96 
97 
100 #ifndef __SYNTHESIS__
101  bool feedAxisRawStreamFromFile(stream<AxisRaw> &ss, const string ssName,
102  string datFile, int &nrChunks,
103  int &nrFrames, int &nrBytes);
104  bool drainAxisRawStreamToFile (stream<AxisRaw> &ss, const string ssName,
105  string datFile, int &nrChunks,
106  int &nrFrames, int &nrBytes);
107  template <class AXIS_T> \
108  bool feedAxisFromFile(stream<AXIS_T> &ss, const string ssName,
109  string datFile, int &nrChunks,
110  int &nrFrames, int &nrBytes);
111  template <class AXIS_T> \
112  bool drainAxisToFile(stream<AXIS_T> &ss, const string ssName,
113  string datFile, int &nrChunks,
114  int &nrFrames, int &nrBytes);
115 #endif
116 
117 #endif
118 
ap_uint< 64 > data
Definition: tb_nal.cpp:832
bool readHostSocketFromLine(SockAddr &hostSock, string stringBuffer)
Retrieve a Host socket from a string.
bool readFpgaSocketFromLine(SockAddr &fpgaSock, string stringBuffer)
Retrieve an Fpga socket from a string.
bool readAxisRawFromLine(AxisRaw &axisRaw, string stringBuffer)
Retrieve an AxisRaw chunk from a string.
bool writeApUintToFile(ap_uint< D > &data, ofstream &outFileStream)
Dump an AP_UINT to a file.
string myUint8ToStrHex(ap_uint< 8 > inputNumber)
Converts an UINT8 into a string of 2 HEX characters.
vector< string > myTokenizer(string strBuff, char delimiter)
Brakes a string into tokens by using the 'delimiter' character.
bool isDatFile(string fileName)
Checks if a file has a ".dat" extension.
Definition: SimNtsUtils.cpp:52
bool writeAxisRawToFile(AxisRaw &axisRaw, ofstream &outFileStream)
Dump an Axis raw data chunk to a file.
bool drainAxisRawStreamToFile(stream< AxisRaw > &ss, const string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
bool isDottedDecimal(string ipStr)
Checks if a string contains an IP address represented in dot-decimal notation.
Definition: SimNtsUtils.cpp:72
ap_uint< 64 > myStrHexToUint64(string dataString)
Converts a string of 16 HEX characters into an UINT64.
bool readTbParamFromFile(const string paramName, const string datFile, unsigned int &paramVal)
Retrieve a testbench parameter from a DAT file.
bool feedAxisFromFile(stream< AXIS_T > &ss, const string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
Initialize an Axi4-Stream (Axis) from a DAT file.
bool drainAxisToFile(stream< AXIS_T > &ss, const string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
Empty an Axi4-Stream (Axis) to a DAT file.
string myUint64ToStrHex(ap_uint< 64 > inputNumber)
Converts an UINT64 into a string of 16 HEX characters.
bool writeSocketPairToFile(SocketPair &socketPair, ofstream &outFileStream)
Dump a SocketPair to a file.
int myDiffTwoFiles(string dataFileName, string goldFileName)
Compares 2 files line-by-line, up to length of the 2nd file.
int writeAxisAppToFile(AxisApp &axisApp, ofstream &outFile)
Dump a TCP or UDP application data chunk into a file. The data are stored as a stream of bytes which ...
ap_uint< 8 > myStrHexToUint8(string keepString)
Converts a string of 2 HEX characters into an UINT8.
bool readAxisRawFromFile(AxisRaw &axisRaw, ifstream &inpFileStream)
Retrieve an Axis raw data chunk from a file.
bool isHexString(string str)
Checks if a string contains a hexadecimal number.
Definition: SimNtsUtils.cpp:90
bool feedAxisRawStreamFromFile(stream< AxisRaw > &ss, const string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
ap_uint< 32 > myDottedDecimalIpToUint32(string ipStr)
Converts an IPv4 address represented with a dotted-decimal string into an UINT32.
bool readFpgaSndPortFromLine(Ly4Port &port, string stringBuffer)
Retrieve an FPGA send port from a string.
ap_uint< 16 > Ly4Port
Definition: nts_types.hpp:201
string fileName
Definition: genTestFile.py:100