36 #include "../../uppercase/include/uppercase.hpp"
37 #include "../../common/src/common.cpp"
45 #define THIS_NAME "TB"
47 #define TRACE_OFF 0x0000
48 #define TRACE_URIF 1 << 1
49 #define TRACE_UAF 1 << 2
50 #define TRACE_MMIO 1 << 3
51 #define TRACE_ALL 0xFFFF
53 #define DEBUG_LEVEL (TRACE_ALL)
63 #define DEBUG_TRACE true
64 #define DEBUG_MULTI_RUNS True
65 #define TB_MULTI_RUNS_ITERATIONS 2
67 #define ENABLED (ap_uint<1>)1
68 #define DISABLED (ap_uint<1>)0
99 #define MEMORY_LINES_512 TOTMEMDW_512
125 printf(
"[%4.4d] STEP DUT \n",
simCnt);
135 int main(
int argc,
char** argv) {
142 printf(
"#####################################################\n");
143 printf(
"## TESTBENCH STARTS HERE ##\n");
144 printf(
"#####################################################\n");
150 printf(
"Usage : %s <input string> , provided %d\n", argv[0], argc);
154 string tmp_string= argv[1];
159 tmp_string = tmp_string.substr(1,tmp_string.length()-2);
162 strInput = tmp_string;
163 if (!strInput.length()) {
164 printf(
"ERROR: Empty string provided. Aborting...\n");
168 printf(
"Succesfully loaded string ... %s\n", argv[1]);
176 unsigned int sim_time = 2 *
CEIL(strInput.length(), 8) + 10;
177 unsigned int tot_trasnfers = (
CEIL(strInput.length(),
PACK_SIZE));
178 char *charOutput = (
char*)malloc(strInput.length() *
sizeof(char));
179 char *charInput = (
char*)malloc(strInput.length() *
sizeof(char));
180 if (!charOutput || !charInput) {
181 printf(
"ERROR: Cannot allocate memory for output string. Aborting...\n");
200 #ifdef DEBUG_MULTI_RUNS
215 printf(
"### ERROR : Failed to set input data stream \"sSHL_Uaf_Data\". \n");
221 for (
unsigned int i=0; i<tot_trasnfers; i++) {
260 printf(
"## End of simulation at cycle=%3d. \n",
simCnt);
282 printf(
"NRC received NRCmeta stream from rank %d to rank %d.\n", (
int) tmp_meta.
tdata.
src_rank, (
int) tmp_meta.
tdata.
dst_rank);
287 assert(i == tot_trasnfers);
290 printf(
"Error No metadata received...\n");
298 printf(
"### ERROR : Failed to set string from file \"ofsUAF_Shl_Data.dat\". \n");
301 printf(
"Input string : ");
302 for (
unsigned int i = 0; i < strInput.length(); i++)
303 printf(
"%c", charInput[i]);
306 printf(
"### ERROR : Failed to set string from file \"ofsUAF_Shl_Data.dat\". \n");
309 __file_write(
"./hls_out.txt", charOutput, strInput.length());
310 printf(
"Output string: ");
311 for (
unsigned int i = 0; i < strInput.length(); i++)
312 printf(
"%c", charOutput[i]);
318 int rc1 = system(
"diff --brief -w -i -y ../../../../test/ofsUAF_Shl_Data.dat \
319 ../../../../test/verify_UAF_Shl_Data.dat");
322 printf(
"## Error : File \'ofsUAF_Shl_Data.dat\' does not match \'verify_UAF_Shl_Data.dat\'.\n");
324 printf(
"Output data in file \'ofsUAF_Shl_Data.dat\' verified.\n");
327 cout<< endl <<
" End the TB with iteration " << iterations << endl << endl;
330 printf(
"#####################################################\n");
333 printf(
"## ERROR - TESTBENCH FAILED (RC=%d) !!! ##\n", nrErr);
335 printf(
"## SUCCESSFULL END OF TESTBENCH (RC=0) ##\n");
337 printf(
"#####################################################\n");
341 #ifdef DEBUG_MULTI_RUNS
346 if(charOutput != NULL){
350 if(charInput != NULL){
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 dumpStringToFile(std::string s, const std::string outFileName, int simCnt)
Initialize an input data stream from a file.
bool setInputDataStream(stream< UdpAppData > &sDataStream, const string dataStreamName, const string inpFileName)
Initialize an input data stream from a file.
bool getOutputDataStream(stream< UdpAppData > &sDataStream, const string dataStreamName, const string outFileName)
Fill an output file with data from an output stream.
void uppercase(ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size, stream< NetworkWord > &siSHL_This_Data, stream< NetworkWord > &soTHIS_Shl_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &soNrc_meta, ap_uint< 32 > *po_rx_ports)
Main process of the Uppercase Application directives.
stream< NetworkMetaStream > siUdp_meta("siUdp_meta")
int main(int argc, char **argv)
Main testbench of Hrris.
stream< NetworkMetaStream > soUdp_meta("soUdp_meta")
#define TB_MULTI_RUNS_ITERATIONS
ap_uint< 1 > piSHL_This_MmioCaptPktEn
ap_uint< 1 > piSHL_This_MmioPostPktEn
stream< UdpWord > sUAF_Shl_Data("sUAF_Shl_Data")
stream< UdpWord > image_stream_from_uppercase("image_stream_from_uppercase")
void stepDut()
Run a single iteration of the DUT model.
stream< UdpWord > sSHL_Uaf_Data("sSHL_Uaf_Data")
ap_uint< 32 > cluster_size
ap_uint< 32 > s_udp_rx_ports