249 stream<axiWord> inputPathInDataFIFO(
"inputPathInDataFIFO");
250 stream<axiWord> inputPathOutDataFIFO(
"inputPathOutDataFIFO");
251 stream<ap_uint<16> > openPortFIFO(
"openPortFIFO");
252 stream<bool> confirmPortStatusFIFO(
"confirmPortStatusFIFO");
253 stream<ap_uint<16> > inputPathPortRealeaseFIFO(
"inputPathPortRealeaseFIFO");
254 stream<metadata> inputPathOutputMetadataFIFO(
"inputPathOutputMetadataFIFO");
255 stream<axiWord> outputPathInDataFIFO(
"outputPathInDataFIFO");
256 stream<axiWord> outputPathOutDataFIFO(
"outputPathOutDataFIFO");
257 stream<metadata> outputPathInMetadataFIFO(
"outputPathInMetadataFIFO");
258 stream<ap_uint<16> > outputpathInLengthFIFO(
"outputpathInLengthFIFO");
259 stream<ipTuple> outIPaddressesFIFO(
"outIPaddressesFIFO");
260 stream<axiWord> outPortUnreachableFIFO(
"outPortUnreachableFIFO");
266 ap_uint<16> openPortData = 0;
267 bool portStatusData =
false;
271 ap_uint<16> outputPathInputLength = 0;
275 uint16_t inputSourceIP = 0;
276 uint16_t inputDestinationIP = 0;
278 std::string dataString;
285 uint32_t errCount = 0;
292 ifstream goldenOutputRx;
293 ifstream goldenOutputTx;
295 uint32_t overflowCounter = 0;
299 std::cout <<
"You need to provide at least one parameter (the input file name)!" << std::endl;
302 rxInput.open(argv[1]);
304 std::cout <<
" Error opening Rx input file!" << std::endl;
307 txInput.open(argv[2]);
309 std::cout <<
" Error opening Tx input file!" << std::endl;
312 rxOutput.open(
"rxOutput.dat");
314 std::cout <<
" Error opening output file!" << std::endl;
317 portStatus.open(
"portStatus.dat");
319 std::cout <<
" Error opening port status file!" << std::endl;
322 txOutput.open(
"txOutput.dat");
324 cout <<
"Error openingn Tx Output file!" << endl;
327 goldenOutputRx.open(
"../../../../sources/goldenOutput/rxGoldenOutput.short.dat");
328 if (!goldenOutputRx) {
329 cout <<
"Error opening golden output file for the Rx side. Check that the correct path is provided!" << endl;
332 goldenOutputTx.open(
"../../../../sources/goldenOutput/txGoldenOutput.short.dat");
333 if (!goldenOutputTx) {
334 cout <<
"Error opening golden output file for the Tx side. Check that the correct path is provided!" << endl;
337 std::cerr <<
"Input File: " << argv[1] << std::endl << std::endl;
339 inputPathPortRealeaseFIFO.write(0x1532);
340 for (
short int i= 0;i<10;++i)
341 udp(inputPathInDataFIFO, inputPathOutDataFIFO, openPortFIFO, confirmPortStatusFIFO,
342 inputPathOutputMetadataFIFO, inputPathPortRealeaseFIFO, outputPathInDataFIFO, outputPathOutDataFIFO, outputPathInMetadataFIFO, outputpathInLengthFIFO, outPortUnreachableFIFO);
346 openPortFIFO.write(0x80);
347 for (
short int i= 0;i<3;++i)
348 udp(inputPathInDataFIFO, inputPathOutDataFIFO, openPortFIFO, confirmPortStatusFIFO,
349 inputPathOutputMetadataFIFO, inputPathPortRealeaseFIFO, outputPathInDataFIFO, outputPathOutDataFIFO, outputPathInMetadataFIFO, outputpathInLengthFIFO, outPortUnreachableFIFO);
351 if (!confirmPortStatusFIFO.empty()) {
352 temp = confirmPortStatusFIFO.read();
353 std::cerr <<
"Port opened successfully!" << std::endl;
356 std::cerr <<
"Error, port not opened successfully." << std::endl;
360 inputPathPortRealeaseFIFO.write(temp);
361 for (
short int i= 0;i<10;++i)
362 udp(inputPathInDataFIFO, inputPathOutDataFIFO, openPortFIFO, confirmPortStatusFIFO,
363 inputPathOutputMetadataFIFO, inputPathPortRealeaseFIFO, outputPathInDataFIFO, outputPathOutDataFIFO, outputPathInMetadataFIFO, outputpathInLengthFIFO, outPortUnreachableFIFO);
366 uint32_t noOfLines = 0;
367 while (!rxInput.eof()) {
368 std::string stringBuffer;
369 getline(rxInput, stringBuffer);
370 std::vector<std::string> stringVector =
parseLine(stringBuffer);
371 string dataString = stringVector[0];
372 string keepString = stringVector[2];
375 inputPathInputData.
last = atoi(stringVector[1].c_str());
376 inputPathInDataFIFO.write(inputPathInputData);
380 while (!inputPathInDataFIFO.empty() || overflowCounter <
maxOverflowValue) {
381 udp(inputPathInDataFIFO, inputPathOutDataFIFO, openPortFIFO, confirmPortStatusFIFO, inputPathOutputMetadataFIFO,
382 inputPathPortRealeaseFIFO, outputPathInDataFIFO, outputPathOutDataFIFO, outputPathInMetadataFIFO, outputpathInLengthFIFO, outPortUnreachableFIFO);
385 if (inputPathInDataFIFO.empty())
389 rxInput.open(argv[1]);
391 cerr << endl <<
"Test 4: Exercising the Rx Path" << endl;
392 openPortFIFO.write(0x80);
393 for (
short int i= 0;i<3;++i)
394 udp(inputPathInDataFIFO, inputPathOutDataFIFO, openPortFIFO, confirmPortStatusFIFO,
395 inputPathOutputMetadataFIFO, inputPathPortRealeaseFIFO, outputPathInDataFIFO, outputPathOutDataFIFO, outputPathInMetadataFIFO, outputpathInLengthFIFO, outPortUnreachableFIFO);
397 if (!confirmPortStatusFIFO.empty()) {
398 temp = confirmPortStatusFIFO.read();
399 std::cerr << endl <<
"Port opened successfully!" << std::endl;
402 std::cerr << endl <<
"Error, port not opened successfully." << std::endl;
407 while (!rxInput.eof()) {
408 std::string stringBuffer;
409 getline(rxInput, stringBuffer);
410 std::vector<std::string> stringVector =
parseLine(stringBuffer);
411 string dataString = stringVector[0];
412 string keepString = stringVector[2];
416 inputPathInputData.
last = atoi(stringVector[1].c_str());
417 inputPathInDataFIFO.write(inputPathInputData);
421 while (!inputPathInDataFIFO.empty() || overflowCounter <
maxOverflowValue) {
422 udp(inputPathInDataFIFO, inputPathOutDataFIFO, openPortFIFO, confirmPortStatusFIFO, inputPathOutputMetadataFIFO,
423 inputPathPortRealeaseFIFO, outputPathInDataFIFO, outputPathOutDataFIFO, outputPathInMetadataFIFO, outputpathInLengthFIFO, outPortUnreachableFIFO);
426 if (inputPathInDataFIFO.empty())
430 cerr << endl <<
"Rx test complete." << endl;
433 cerr << endl <<
"Test 5: Exercising the Tx Path" << endl;
436 while (!txInput.eof()) {
437 std::string stringBuffer;
438 getline(txInput, stringBuffer);
439 std::vector<std::string> stringVector =
parseLine(stringBuffer);
440 string sourcePort = stringVector[0];
441 string destinationPort = stringVector[1];
442 string sourceIP = stringVector[2];
443 string destinationIP = stringVector[3];
444 string payloadLength = stringVector[4];
445 string dataString = stringVector[5];
446 string keepString = stringVector[6];
449 outputPathInData.
last = atoi(stringVector[7].c_str());
455 outputPathInDataFIFO.write(outputPathInData);
456 if (outputPathInputLength != 0) {
457 outputPathInMetadataFIFO.write(outputPathInputMetadata);
458 outputpathInLengthFIFO.write(outputPathInputLength);
463 while (!outputPathInDataFIFO.empty() || overflowCounter <
maxOverflowValue) {
464 udp(inputPathInDataFIFO, inputPathOutDataFIFO, openPortFIFO, confirmPortStatusFIFO, inputPathOutputMetadataFIFO,
465 inputPathPortRealeaseFIFO, outputPathInDataFIFO, outputPathOutDataFIFO, outputPathInMetadataFIFO, outputpathInLengthFIFO, outPortUnreachableFIFO);
468 if (outputPathInDataFIFO.empty())
473 cerr << endl <<
"Tx test complete. Verifying result." << endl;
475 while (!outputPathOutDataFIFO.empty()) {
476 axiWord tempOutput = outputPathOutDataFIFO.read();
477 goldenOutputTx >> hex >> txCompareOutput.
data >> txCompareOutput.
last >> txCompareOutput.
keep;
478 if (txCompareOutput.
data != tempOutput.
data || txCompareOutput.
last != tempOutput.
last || txCompareOutput.
keep != tempOutput.
keep) {
486 txOutput << dataOutput <<
" " << tempOutput.
last <<
" " << keepOutput << endl;
494 while (!inputPathOutDataFIFO.empty() && !goldenOutputRx.eof()) {
498 axiWord tempOutput = inputPathOutDataFIFO.read();
499 goldenOutputRx >> hex >> compareWord.
data >> compareWord.
last;
500 if (compareWord.
data != tempOutput.
data || compareWord.
last != tempOutput.
last) {
507 rxOutput << dataOutput <<
" " << tempOutput.
last << endl;
510 cerr << endl <<
"Errors during testing. Check the output file." << endl;
513 cerr << endl <<
"All Tests passed succesfully." << endl;
515 while(!outPortUnreachableFIFO.empty())
516 outPortUnreachableFIFO.read();
517 while(!inputPathOutputMetadataFIFO.empty())
518 inputPathOutputMetadataFIFO.read();
519 while(!inputPathOutDataFIFO.empty())
520 inputPathOutDataFIFO.read();
ap_uint< 16 > encodeApUint16(string parseString)
ap_uint< 64 > encodeApUint64(string dataString)
ap_uint< 32 > encodeApUint32(string parseString)
string decodeApUint8(ap_uint< 8 > inputNumber)
ap_uint< 8 > encodeApUint8(string keepString)
std::vector< std::string > parseLine(std::string stringBuffer)
string decodeApUint64(ap_uint< 64 > inputNumber)