28 #include <hls_stream.h>
30 #include "../src/upper_lower_app.hpp"
39 #define DEBUG_TRACE true
41 #define ENABLED (ap_uint<1>)1
42 #define DISABLED (ap_uint<1>)0
80 printf(
"[%4.4d] STEP DUT \n",
simCnt);
92 bool setInputDataStream(stream<UdpWord> &sDataStream,
const string dataStreamName,
const string inpFileName) {
94 ifstream inpFileStream;
95 string datFile =
"../../../../test/" + inpFileName;
99 inpFileStream.open(datFile.c_str());
100 if ( !inpFileStream ) {
101 cout <<
"### ERROR : Could not open the input data file " << datFile << endl;
106 while (inpFileStream) {
108 if (!inpFileStream.eof()) {
110 getline(inpFileStream, strLine);
111 if (strLine.empty())
continue;
112 sscanf(strLine.c_str(),
"%llx %x %d", &udpWord.
tdata, &udpWord.
tkeep, &udpWord.
tlast);
115 if (sDataStream.full()) {
116 printf(
"### ERROR : Stream is full. Cannot write stream with data from file \"%s\".\n", inpFileName.c_str());
119 sDataStream.write(udpWord);
121 printf(
"[%4.4d] TB is filling input stream [%s] - Data write = {D=0x%16.16llX, K=0x%2.2X, L=%d} \n",
122 simCnt, dataStreamName.c_str(),
123 udpWord.
tdata.to_long(), udpWord.
tkeep.to_int(), udpWord.
tlast.to_int());
129 inpFileStream.close();
148 sDataStream.read(*udpWord);
162 if (!outFileStream.is_open()) {
163 printf(
"### ERROR : Output file stream is not open. \n");
166 outFileStream << hex << noshowbase << setfill(
'0') << setw(16) << udpWord->
tdata.to_uint64();
167 outFileStream <<
" ";
168 outFileStream << hex << noshowbase << setfill(
'0') << setw(2) << udpWord->
tkeep.to_int();
169 outFileStream <<
" ";
170 outFileStream << setw(1) << udpWord->
tlast.to_int() <<
"\n";
185 const string dataStreamName,
const string outFileName)
188 ofstream outFileStream;
189 string datFile =
"../../../../test/" + outFileName;
194 outFileStream.open(datFile.c_str());
195 if ( !outFileStream ) {
196 cout <<
"### ERROR : Could not open the output data file " << datFile << endl;
201 while (!sDataStream.empty()) {
204 printf(
"[%4.4d] TB is draining output stream [%s] - Data read = {D=0x%16.16llX, K=0x%2.2X, L=%d} \n",
205 simCnt, dataStreamName.c_str(),
206 udpWord.
tdata.to_long(), udpWord.
tkeep.to_int(), udpWord.
tlast.to_int());
215 outFileStream.close();
228 printf(
"#####################################################\n");
229 printf(
"## TESTBENCH STARTS HERE ##\n");
230 printf(
"#####################################################\n");
240 printf(
"### ERROR : Failed to set input data stream \"sSHL_Uaf_Data\". \n");
282 printf(
"## End of simulation at cycle=%3d. \n",
simCnt);
304 printf(
"NRC received NRCmeta stream to rank %d.\n", (
int) tmp_meta.
tdata.
dst_rank);
311 printf(
"Error No metadata received...\n");
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");
329 printf(
"#####################################################\n");
331 printf(
"## ERROR - TESTBENCH FAILED (RC=%d) !!! ##\n", nrErr);
333 printf(
"## SUCCESSFULL END OF TESTBENCH (RC=0) ##\n");
335 printf(
"#####################################################\n");
void stepDut()
Run a single iteration of the DUT model.
bool setInputDataStream(stream< UdpAppData > &sDataStream, const string dataStreamName, const string inpFileName)
Initialize an input data stream from a file.
bool readDataStream(stream< UdpAppData > &sDataStream, UdpAppData *udpWord)
Read data from a stream.
bool dumpDataToFile(UdpAppData *udpWord, ofstream &outFileStream)
Dump a data word to a file.
bool getOutputDataStream(stream< UdpAppData > &sDataStream, const string dataStreamName, const string outFileName)
Fill an output file with data from an output stream.
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 > cluster_size
ap_uint< 32 > s_udp_rx_ports
void upper_lower_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, invert the case of A...