33 #ifndef _TEST_COMMON_H_
34 #define _TEST_COMMON_H_
39 #include <hls_stream.h>
46 #ifdef ROLE_IS_UPPERCASE
47 #include "../../../../../HOST/custom/uppercase/languages/cplusplus/include/config.h"
48 #include "../../uppercase/include/uppercase.hpp"
51 #ifdef ROLE_IS_MEMTEST
52 #include "../../memtest/include/memtest.hpp"
53 #include "../../../../../HOST/custom/memtest/languages/cplusplus/include/config.h"
56 #include <bits/stdc++.h>
63 #define THIS_NAME "TB"
65 #define TRACE_OFF 0x0000
66 #define TRACE_URIF 1 << 1
67 #define TRACE_UAF 1 << 2
68 #define TRACE_MMIO 1 << 3
69 #define TRACE_ALL 0xFFFF
71 #define DEBUG_LEVEL (TRACE_ALL)
81 #define DEBUG_TRACE true
83 #define ENABLED (ap_uint<1>)1
84 #define DISABLED (ap_uint<1>)0
118 const std::string inpFileName,
int simCnt);
162 const std::string dataStreamName,
const std::string outFileName,
int simCnt);
212 template<
unsigned int bytes_per_line = 8>
221 unsigned char hexval(
unsigned char c);
312 template<
unsigned int bytes_per_line=8>
313 std::vector<MemoryTestResult>
parseMemoryTestOutput(
const std::string longbuf,
size_t charOutputSize,
int rawdatalines);
342 static inline ssize_t
343 __file_size(
const char *fname);
345 static inline ssize_t
346 __file_read(
const char *fname,
char *buff,
size_t len);
348 static inline ssize_t
349 __file_write(
const char *fname,
const char *buff,
size_t len);
bool dumpStringToFileOnlyRawData(const std::string s, const std::string outFileName, int simCnt, size_t out_size)
Fill an output file with data from an image.
ap_uint< 64 > pack_ap_uint_64_(ap_uint< 8 > *buffer)
Pack an array of 8 x ap_uint<8> into a ap_uint<64> word.
bool dumpFileToString(const std::string inpFileName, std::string strOutput, int simCnt)
Initialize an input data stream from a file.
bool isCornerPresent(std::string str, std::string corner)
Check the presence of a given corner value at the begin and the end of a string.
bool dumpStringToFileWithLastSetEveryGnoPackets(std::string s, const std::string outFileName, int simCnt, int gno)
Fill an output file with data from a string and set the tlast every gno packets.
bool setInputDataStream(stream< UdpWord > &sDataStream, const std::string dataStreamName, const std::string inpFileName, int simCnt)
Initialize an input data stream from a file.
bool readDataStream(stream< UdpWord > &sDataStream, UdpWord *udpWord)
Read data from a stream.
void reverseStr(std::string &str)
reverse a given string
bool dumpDataToFile(UdpWord *udpWord, std::ofstream &outFileStream)
Dump a data word to a file.
bool getOutputDataStream(stream< UdpWord > &sDataStream, const std::string dataStreamName, const std::string outFileName, int simCnt)
Fill an output file with data from an output stream.
std::string createMemTestGoldenOutput(unsigned long long int mem_address, int testingNumber)
Create the expected output results for the memory test (with FAULT INJECTION)
bool dumpStringToFile(std::string s, const std::string outFileName, int simCnt)
Initialize an input data stream from a file.
std::string createUppercaseGoldenOutput(std::string input_string)
Create the expected output results for the uppercase.
void ascii2hex(const string &in, string &out)
Convert a ascii string to a hexadecimal string.
unsigned char hexval(unsigned char c)
convert a char to its hexadecimal representation.
unsigned long long int clock_cycles_read
std::vector< MemoryTestResult > parseMemoryTestOutput(const string longbuf, size_t charOutputSize, int rawdatalines)
Parse the memory test output contained in astring with a given size.
string dumpFileToStringRawDataString(const string inpFileName, int *rawdatalines, size_t outputSize)
Initialize an input data stream from a file with only data.
void printBits(size_t const size, void const *const ptr)
print the binary representation of a target pointer buffer of a given size. Assumes little endian.
unsigned int first_fault_address
void printCharBuffHex(const char *inStr, size_t strSize)
print byte-per-byte a given char buff in hexadecimal format
void ascii2hexWithSize(const string &in, string &out, size_t bytesize)
Convert a ascii string to a hexadecimal string.
string createMemTestCommands(unsigned long long int mem_address, unsigned int testingNumber, unsigned int burst_size)
Create the commands for a memory test with start/max address to test-nop to execute-stop.
void string2hexnumerics(const string &in, char *out, size_t byteSize)
unsigned long long int clock_cycles_write
void printStringHex(const string inStr, size_t strSize)
print byte-per-byte a given string in hexadecimal format
void hex2ascii(const string &in, string &out)
Convert a hexadecimal string to a ascii string.
unsigned long long int target_address
MemoryTestResult(unsigned long long int target_address, unsigned int fault_cntr, unsigned int first_fault_address, unsigned long long int clock_cycles_write, unsigned long long int clock_cycles_read)