29 #include <hls_stream.h>
31 #include "../src/triangle_app.hpp"
40 #define DEBUG_TRACE true
42 #define ENABLED (ap_uint<1>)1
43 #define DISABLED (ap_uint<1>)0
81 printf(
"[%4.4d] STEP DUT \n",
simCnt);
93 bool setInputDataStream(stream<UdpWord> &sDataStream,
const string dataStreamName,
const string inpFileName) {
95 ifstream inpFileStream;
96 string datFile =
"../../../../test/" + inpFileName;
100 inpFileStream.open(datFile.c_str());
101 if ( !inpFileStream ) {
102 cout <<
"### ERROR : Could not open the input data file " << datFile << endl;
107 while (inpFileStream) {
109 if (!inpFileStream.eof()) {
111 getline(inpFileStream, strLine);
112 if (strLine.empty())
continue;
113 sscanf(strLine.c_str(),
"%llx %x %d", &udpWord.
tdata, &udpWord.
tkeep, &udpWord.
tlast);
116 if (sDataStream.full()) {
117 printf(
"### ERROR : Stream is full. Cannot write stream with data from file \"%s\".\n", inpFileName.c_str());
120 sDataStream.write(udpWord);
122 printf(
"[%4.4d] TB is filling input stream [%s] - Data write = {D=0x%16.16llX, K=0x%2.2X, L=%d} \n",
123 simCnt, dataStreamName.c_str(),
124 udpWord.
tdata.to_long(), udpWord.
tkeep.to_int(), udpWord.
tlast.to_int());
130 inpFileStream.close();
149 sDataStream.read(*udpWord);
163 if (!outFileStream.is_open()) {
164 printf(
"### ERROR : Output file stream is not open. \n");
167 outFileStream << hex << noshowbase << setfill(
'0') << setw(16) << udpWord->
tdata.to_uint64();
168 outFileStream <<
" ";
169 outFileStream << hex << noshowbase << setfill(
'0') << setw(2) << udpWord->
tkeep.to_int();
170 outFileStream <<
" ";
171 outFileStream << setw(1) << udpWord->
tlast.to_int() <<
"\n";
186 const string dataStreamName,
const string outFileName)
189 ofstream outFileStream;
190 string datFile =
"../../../../test/" + outFileName;
195 outFileStream.open(datFile.c_str());
196 if ( !outFileStream ) {
197 cout <<
"### ERROR : Could not open the output data file " << datFile << endl;
202 while (!sDataStream.empty()) {
205 printf(
"[%4.4d] TB is draining output stream [%s] - Data read = {D=0x%16.16llX, K=0x%2.2X, L=%d} \n",
206 simCnt, dataStreamName.c_str(),
207 udpWord.
tdata.to_long(), udpWord.
tkeep.to_int(), udpWord.
tlast.to_int());
216 outFileStream.close();
229 printf(
"#####################################################\n");
230 printf(
"## TESTBENCH STARTS HERE ##\n");
231 printf(
"#####################################################\n");
241 printf(
"### ERROR : Failed to set input data stream \"sSHL_Uaf_Data\". \n");
283 printf(
"## End of simulation at cycle=%3d. \n",
simCnt);
305 printf(
"NRC received NRCmeta stream to rank %d.\n", (
int) tmp_meta.
tdata.
dst_rank);
312 printf(
"Error No metadata received...\n");
319 int rc1 = system(
"diff --brief -w -i -y ../../../../test/ofsUAF_Shl_Data.dat \
320 ../../../../test/ifsSHL_Uaf_Data.dat");
322 printf(
"## Error : File \'ofsUAF_Shl_Data.dat\' does not match \'ifsSHL_Uaf_Data.dat\'.\n");
326 printf(
"#####################################################\n");
328 printf(
"## ERROR - TESTBENCH FAILED (RC=%d) !!! ##\n", nrErr);
330 printf(
"## SUCCESSFULL END OF TESTBENCH (RC=0) ##\n");
332 printf(
"#####################################################\n");
bool getOutputDataStream(stream< UdpWord > &sDataStream, const string dataStreamName, const string outFileName)
Fill an output file with data from an output stream.
bool readDataStream(stream< UdpWord > &sDataStream, UdpWord *udpWord)
Read data from a stream.
bool dumpDataToFile(UdpWord *udpWord, ofstream &outFileStream)
Dump a data word to a file.
void stepDut()
Run a single iteration of the DUT model.
bool setInputDataStream(stream< UdpWord > &sDataStream, const string dataStreamName, const string inpFileName)
Initialize an input data stream from a file.
stream< NetworkMetaStream > siUdp_meta("siUdp_meta")
stream< NetworkMetaStream > soUdp_meta("soUdp_meta")
ap_uint< 1 > piSHL_This_MmioCaptPktEn
ap_uint< 1 > piSHL_This_MmioPostPktEn
stream< UdpWord > sUAF_Shl_Data("sUAF_Shl_Data")
stream< UdpWord > sSHL_Uaf_Data("sSHL_Uaf_Data")
ap_uint< 32 > s_udp_rx_ports
void triangle_app(ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size, stream< NetworkWord > &siNrc_data, stream< NetworkWord > &soNrc_data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &soNrc_meta, ap_uint< 32 > *po_rx_ports)
Main process of the UDP/TCP Triangle Application. This HLS IP receives a packet and forwards it to th...