cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_iptx.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 -- 2021 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
30 #include "test_iptx.hpp"
31 
32 using namespace hls;
33 using namespace std;
34 
35 //---------------------------------------------------------
36 // HELPERS FOR THE DEBUGGING TRACES
37 // .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)
38 //---------------------------------------------------------
39 #define THIS_NAME "TB"
40 
41 #define TRACE_OFF 0x0000
42 #define TRACE_CGF 1 << 1
43 #define TRACE_ARP 1 << 2
44 #define TRACE_ALL 0xFFFF
45 
46 #define DEBUG_LEVEL (TRACE_OFF)
47 
48 
51 void stepSim() {
52  gSimCycCnt++;
53  if (gTraceEvent || ((gSimCycCnt % 1000) == 0)) {
54  printInfo(THIS_NAME, "-- [@%4.4d] -----------------------------\n", gSimCycCnt);
55  gTraceEvent = false;
56  }
57  else if (0) {
58  printInfo(THIS_NAME, "------------------- [@%d] ------------\n", gSimCycCnt);
59  }
60 }
61 
62 
73  stream<Ip4Addr> &siIPTX_LookupReq,
74  stream<ArpLkpReply> &soIPTX_LookupRep,
75  EthAddr piMacAddress,
76  Ip4Addr piIp4Address,
77  Ip4Addr piSubNetMask,
78  Ip4Addr piGatewayAddr)
79 {
80  const char *myName = concat3(THIS_NAME, "/", "ARP");
81 
82  static bool macAddrOfGatewayIsResolved = false;
83  Ip4Addr ip4ToMacLkpReq;
84 
85  if (!siIPTX_LookupReq.empty()) {
86  siIPTX_LookupReq.read(ip4ToMacLkpReq);
87  if (DEBUG_LEVEL & TRACE_ARP) {
88  printIp4Addr(myName, "Received a lookup request from [IPTX] with key = ",
89  ip4ToMacLkpReq);
90  }
91  if (ip4ToMacLkpReq == piGatewayAddr) {
92  // The ARP replies with the MAC address of the default gateway.
93  if (macAddrOfGatewayIsResolved) {
94  EthAddr aComposedMacAddr = 0xFECA00000000 | piGatewayAddr;
95  soIPTX_LookupRep.write(ArpLkpReply(aComposedMacAddr, true));
96  if (DEBUG_LEVEL & TRACE_ARP) {
97  printInfo(myName, "MAC lookup = HIT - Replying with MAC = 0x%12.12lX\n",
98  aComposedMacAddr.to_ulong());
99  }
100  }
101  else {
102  // For the very first occurrence of such an event, the ARP
103  // replies with a 'NO-HIT' while firing an ARP-Request in order
104  // to retrieve the MAC address of the default gateway.
105  EthAddr aComposedMacAddr = 0xADDE00000000 | piGatewayAddr;
106  soIPTX_LookupRep.write(ArpLkpReply(aComposedMacAddr, false));
107  printWarn(myName, "Result of MAC lookup = NO-HIT \n");
108  macAddrOfGatewayIsResolved = true;
109  }
110  }
111  else if ((ip4ToMacLkpReq & piSubNetMask) == (piGatewayAddr & piSubNetMask)) {
112  // The remote IPv4 address falls into our sub-network
113  EthAddr aComposedMacAddr = 0xFECA00000000 | ip4ToMacLkpReq;
114  soIPTX_LookupRep.write(ArpLkpReply(aComposedMacAddr, true));
115  if (DEBUG_LEVEL & TRACE_ARP) {
116  printInfo(myName, "MAC lookup = HIT - Replying with MAC = 0x%12.12lX\n",
117  aComposedMacAddr.to_ulong());
118  }
119  }
120  else {
121  printWarn(myName, "Result of MAC lookup = NO-HIT \n");
122  }
123  }
124 }
125 
126 
139  string inpDAT_FileName,
140  string outDAT_GoldName,
141  EthAddr myMacAddress,
142  Ip4Addr myIp4Address,
143  Ip4Addr mySubNetMask,
144  Ip4Addr myGatewayAddr)
145 {
146  const char *myName = concat3(THIS_NAME, "/", "CGF");
147 
148  ifstream ifsDAT;
149  ofstream ofsDAT;
150 
151  char currPath[FILENAME_MAX];
152  int ret=NTS_OK;
153  int inpChunks=0, outChunks=0;
154  int inpPackets=0, outFrames=0;
155  int inpBytes=0, outBytes=0;
156  bool macAddrOfGatewayIsResolved = false;
157 
158  //-- STEP-1 : OPEN INPUT FILE AND ASSESS ITS EXTENSION
159  ifsDAT.open(inpDAT_FileName.c_str());
160  if (!ifsDAT) {
161  getcwd(currPath, sizeof(currPath));
162  printError("TB", "Cannot open the file: %s \n\t (FYI - The current working directory is: %s) \n",
163  inpDAT_FileName.c_str(), currPath);
164  return(NTS_KO);
165  }
166  if (not isDatFile(inpDAT_FileName)) {
167  printError("TB", "Cannot create golden files from input file \'%s\' because file is not of type \'.dat\'.\n",
168  inpDAT_FileName.c_str());
169  ifsDAT.close();
170  return(NTS_KO);
171  }
172 
173  //-- STEP-2 : OPEN THE OUTPUT GOLD FILE
174  remove(outDAT_GoldName.c_str());
175  if (!ofsDAT.is_open()) {
176  ofsDAT.open (outDAT_GoldName.c_str(), ofstream::out);
177  if (!ofsDAT) {
178  printFatal(THIS_NAME, "Could not open the output gold file \'%s\'. \n",
179  outDAT_GoldName.c_str());
180  }
181  }
182 
183  //-- STEP-3 : READ AND PARSE THE INPUT IPv4 FILE
184  while ((ifsDAT.peek() != EOF) && (ret != NTS_KO)) {
185  SimIp4Packet ipPacket;
186  AxisIp4 axisIp4;
187  bool endOfPacket=false;
188  bool rc;
189  // Build a new frame from IPv4 data file
190  while ((ifsDAT.peek() != EOF) && (!endOfPacket)) {
191  rc = readAxisRawFromFile(axisIp4, ifsDAT);
192  if (rc) {
193  if (axisIp4.isValid()) {
194  ipPacket.pushChunk(axisIp4);
195  if (axisIp4.getLE_TLast()) {
196  inpPackets++;
197  endOfPacket = true;
198  }
199  }
200  else {
201  // We always abort the stream as this point by asserting
202  // 'tlast' and de-asserting 'tkeep'.
203  ipPacket.pushChunk(AxisIp4(axisIp4.getLE_TData(), 0x00, TLAST));
204  inpPackets++;
205  endOfPacket = true;
206  }
207  inpChunks++;
208  inpBytes += axisIp4.getLen();
209  }
210  }
211  if (endOfPacket) {
212  Ip4Addr ipSA = ipPacket.getIpSourceAddress();
213  if(ipSA != myIp4Address) {
214  printWarn(THIS_NAME, "Packet #%d is dropped because IP_SA does not match.\n",
215  inpPackets);
216  printIp4Addr(THIS_NAME, " Received", ipSA);
217  printIp4Addr(THIS_NAME, " Expected", myIp4Address);
218  }
219  else if (not ipPacket.isWellFormed(myName)) {
220  printError(myName, "IP packet #%d is dropped because it is malformed.\n", inpPackets);
221  endOfPacket=false;
222  }
223  else {
224  SimEthFrame ethGoldFrame(14);
225  //-------------------------------
226  //-- SET THE MAC HEADER --
227  //-------------------------------
228  Ip4Addr ipDA = ipPacket.getIpDestinationAddress();
229  // Create MAC_DA from IP_DA (for testing purposes)
230  if ((ipDA & mySubNetMask) == (myGatewayAddr & mySubNetMask)) {
231  // The remote IPv4 address falls into our sub-network
232  EthAddr macDaAddr = 0xFECA00000000 | ipDA;
233  ethGoldFrame.setMacDestinAddress(macDaAddr);
234  }
235  else {
236  // The remote IPv4 address falls out of our sub-network.
237  // The ARP is assumed to reply with the MAC address of the default gateway.
238  if (macAddrOfGatewayIsResolved) {
239  EthAddr aComposedMacAddr = 0xFECA00000000 | myGatewayAddr;
240  if (DEBUG_LEVEL & TRACE_CGF) {
241  printInfo(myName, "Packet with remote IPv4 address to fall out of our sub-network.\n");
242  printInfo(myName, "\tThe IP address of this packet is binded with the MAC address of the default gateway.\n");
243  }
244  }
245  else {
246  printWarn(myName, "First packet with remote IPv4 address to fall out of our sub-network.\n");
247  printIp4Addr(myName, "\tThis packet will be dropped. Remote", ipDA);
248  // For the very first occurrence of such an event, the ARP
249  // replies with a 'NO-HIT' while firing an ARP-Request in order to
250  // retrieve the MAC address of the default gateway for the nest time.
251  macAddrOfGatewayIsResolved = true;
252  continue;
253  }
254  }
255  ethGoldFrame.setMacSourceAddress(myMacAddress);
256  ethGoldFrame.setTypeLength(0x0800);
257  // Assess the IP version
258  if (ipPacket.getIpVersion() != 4) {
259  printWarn(THIS_NAME, "Frame #%d is dropped because IP version is not \'4\'.\n", inpPackets);
260  continue;
261  }
262  // Assess the IP header checksum
263  if (ipPacket.getIpHeaderChecksum() == 0) {
264  // Remember: The TOE delivers packets with the header checksum set to zero
265  Ip4HdrCsum reComputedHdCsum = ipPacket.reCalculateIpHeaderChecksum();
266  }
267  // Assess the L3 checksum
268  switch (ipPacket.getIpProtocol()) {
269  case IP4_PROT_TCP:
270  if (not ipPacket.tcpVerifyChecksum()) {
271  printWarn(THIS_NAME, "Failed to verify the TCP checksum of Frame #%d.\n", inpPackets);
272  }
273  break;
274  case IP4_PROT_UDP:
275  if (not ipPacket.udpVerifyChecksum()) {
276  printWarn(THIS_NAME, "Failed to verify the UDP checksum of Frame #%d.\n", inpPackets);
277  }
278  break;
279  case IP4_PROT_ICMP:
280  break; // [TODO]
281  }
282  // Add the IP packet as data payload of the ETHERNET frame.
283  ethGoldFrame.addPayload(ipPacket);
284  if (ethGoldFrame.writeToDatFile(ofsDAT) == false) {
285  printError(THIS_NAME, "Failed to write ETH frame to DAT file.\n");
286  rc = NTS_KO;
287  }
288  else {
289  outFrames += 1;
290  outChunks += ethGoldFrame.size();
291  outBytes += ethGoldFrame.length();
292  }
293  }
294  } // End-of if (endOfPacket)
295  } // End-of While ()
296 
297  //-- STEP-3: CLOSE FILES
298  ifsDAT.close();
299  ofsDAT.close();
300 
301  //-- STEP-4: PRINT RESULTS
302  printInfo(THIS_NAME, "Done with the creation of the golden file.\n");
303  printInfo(THIS_NAME, "\tProcessed %5d chunks in %4d packets, for a total of %6d bytes.\n",
304  inpChunks, inpPackets, inpBytes);
305  printInfo(THIS_NAME, "\tGenerated %5d chunks in %4d frames, for a total of %6d bytes.\n\n",
306  outChunks, outFrames, outBytes);
307  return(ret);
308 }
309 
310 #if HLS_VERSION != 2017
311 
329  //-- MMIO Interfaces
330  EthAddr piMMIO_MacAddress,
331  Ip4Addr piMMIO_SubNetMask,
332  Ip4Addr piMMIO_GatewayAddr,
333  //-- L3MUX Interface
334  stream<AxisIp4> &siL3MUX_Data,
335  //-- L2MUX Interface
336  stream<AxisEth> &soL2MUX_Data,
337  //-- ARP Interface
338  stream<Ip4Addr> &soARP_LookupReq,
339  stream<ArpLkpReply> &siARP_LookupRep)
340 {
341  //-- LOCAL INPUT and OUTPUT STREAMS -------------------
342  stream<AxisRaw> ssiL3MUX_Data ("ssiL3MUX_Data");
343  stream<AxisRaw> ssoL2MUX_Data ("ssoL2MUX_Data");
344 
345  //-- INPUT STREAM CASTING -----------------------------
346  pAxisRawCast(siL3MUX_Data, ssiL3MUX_Data);
347 
348  //-- MAIN IPTX_TOP PROCESS ----------------------------
349  iptx_top(
350  piMMIO_MacAddress,
351  piMMIO_SubNetMask,
352  piMMIO_GatewayAddr,
353  ssiL3MUX_Data,
354  ssoL2MUX_Data,
355  soARP_LookupReq,
356  siARP_LookupRep);
357 
358  //-- OUTPUT STREAM CASTING ----------------------------
359  pAxisRawCast(ssoL2MUX_Data, soL2MUX_Data);
360 }
361 #endif
362 
363 
368 int main(int argc, char* argv[]) {
369 
370  //------------------------------------------------------
371  //-- TESTBENCH GLOBAL VARIABLES
372  //------------------------------------------------------
373  gTraceEvent = false;
374  gFatalError = false;
375  gSimCycCnt = 0;
377 
378  //------------------------------------------------------
379  //-- TESTBENCH LOCAL VARIABLES
380  //------------------------------------------------------
381  int nrErr = 0;
382  int tbRun = 0;
383  EthAddr myMacAddress = 0x60504030201;
384  Ip4Addr mySubNetMask = 0xFFFF0000; // 255.255.000.0
385  Ip4Addr myIp4Address = 0x0A0CC807; // 10.012.200.7
386  Ip4Addr myGatewayAddr = 0x0A0C0001; // 10.012.000.1
387 
388  string ofsL2MUX_Data_FileName = "../../../../test/simOutFiles/soL2MUX_Data.dat";
389  string ofsL2MUX_Gold_FileName = "../../../../test/simOutFiles/soL2MUX_Gold.dat";
390 
391  //------------------------------------------------------
392  //-- DUT STREAM INTERFACES and RELATED VARIABLEs
393  //------------------------------------------------------
394  //-- From L3MUX
395  stream<AxisIp4> ssL3MUX_IPTX_Data ("ssL3MUX_IPTX_Data");
396  int nrL3MUX_IPTX_Chunks = 0;
397  int nrL3MUX_IPTX_Frames = 0;
398  int nrL3MUX_IPTX_Bytes = 0;
399  //-- To L2MUX
400  stream<AxisEth> ssIPTX_L2MUX_Data ("ssIPTX_L2MUX_Data");
401  int nrIPTX_L2MUX_Chunks = 0;
402  int nrIPTX_L2MUX_Frames = 0;
403  int nrIPTX_L2MUX_Bytes = 0;
404  //-- To/From ARP
405  stream<Ip4Addr> ssIPTX_ARP_LookupReq ("ssIPTX_ARP_LookupReq");
406  stream<ArpLkpReply> ssARP_IPTX_LookupRep ("ssARP_IPTX_LookupRep");
407 
408  //------------------------------------------------------
409  //-- READ GLOBAL PARAMETERS FROM INPUT TEST VECTOR FILE
410  //------------------------------------------------------
411  if (argc != 2) {
412  printFatal(THIS_NAME, "Missing testbench parameter:\n\t Expecting an input test vector file.\n");
413  }
414  unsigned int param;
415  if (readTbParamFromFile("FpgaIp4Addr", string(argv[1]), param)) {
416  myIp4Address = param;
417  printIp4Addr(THIS_NAME, "The input test vector is setting the IP address of the FPGA to", myIp4Address);
418  }
419 
420  //------------------------------------------------------
421  //-- CREATE DUT INPUT TRAFFIC AS STREAMS
422  //------------------------------------------------------
423  if (feedAxisFromFile<AxisIp4>(ssL3MUX_IPTX_Data, "ssL3MUX_IPTX_Data", string(argv[1]),
424  nrL3MUX_IPTX_Chunks, nrL3MUX_IPTX_Frames, nrL3MUX_IPTX_Bytes)) {
425  printInfo(THIS_NAME, "Done with the creation of the input traffic as streams:\n");
426  printInfo(THIS_NAME, "\tGenerated %d chunks in %d frames, for a total of %d bytes.\n\n",
427  nrL3MUX_IPTX_Chunks, nrL3MUX_IPTX_Frames, nrL3MUX_IPTX_Bytes);
428  }
429  else {
430  printError(THIS_NAME, "Failed to create traffic as input stream. \n");
431  nrErr++;
432  }
433 
434  //------------------------------------------------------
435  //-- CREATE DUT OUTPUT TRAFFIC AS STREAMS
436  //------------------------------------------------------
437  ofstream outFileStream;
438  //-- Remove previous file
439  remove(ofsL2MUX_Data_FileName.c_str());
440  //-- Assess that file has ".dat" extension
441  if (not isDatFile(ofsL2MUX_Data_FileName)) {
442  printError(THIS_NAME, "File \'%s\' is not of type \'DAT\'.\n", ofsL2MUX_Data_FileName.c_str());
443  outFileStream.close();
444  nrErr++;
445  }
446  //-- Open file
447  if (!outFileStream.is_open()) {
448  outFileStream.open(ofsL2MUX_Data_FileName.c_str(), ofstream::out);
449  if (!outFileStream) {
450  printError(THIS_NAME, "Cannot open the file: \'%s\'.\n", ofsL2MUX_Data_FileName.c_str());
451  nrErr++;
452  }
453  }
454  //-- Read from stream and write to file
455  outFileStream << std::hex << std::noshowbase;
456  outFileStream << std::setfill('0');
457  outFileStream << std::uppercase;
458 
459  //------------------------------------------------------
460  //-- CREATE OUTPUT GOLD TRAFFIC
461  //------------------------------------------------------
462  if (not createGoldenFile(string(argv[1]), ofsL2MUX_Gold_FileName,
463  myMacAddress, myIp4Address, mySubNetMask, myGatewayAddr)) {
464  printError(THIS_NAME, "Failed to create golden file. \n");
465  nrErr++;
466  }
467 
468  printInfo(THIS_NAME, "############################################################################\n");
469  printInfo(THIS_NAME, "## TESTBENCH 'test_iptx' STARTS HERE ##\n");
470  printInfo(THIS_NAME, "############################################################################\n");
471  printInfo(THIS_NAME, "This testbench will be executed with the following parameters: \n");
472  for (int i=1; i<argc; i++) {
473  printInfo(THIS_NAME, "\t==> Param[%d] = %s\n", (i-1), argv[i]);
474  }
475  printf("\n\n");
476 
477  tbRun = (nrErr == 0) ? (nrL3MUX_IPTX_Chunks + TB_GRACE_TIME) : 0;
478 
479  while (tbRun) {
480  //-- RUN DUT --------------------------------------
481  #if HLS_VERSION == 2017
482  iptx_top(
483  myMacAddress,
484  mySubNetMask,
485  myGatewayAddr,
486  ssL3MUX_IPTX_Data,
487  ssIPTX_L2MUX_Data,
488  ssIPTX_ARP_LookupReq,
489  ssARP_IPTX_LookupRep
490  );
491  #else
493  myMacAddress,
494  mySubNetMask,
495  myGatewayAddr,
496  ssL3MUX_IPTX_Data,
497  ssIPTX_L2MUX_Data,
498  ssIPTX_ARP_LookupReq,
499  ssARP_IPTX_LookupRep
500  );
501  #endif
502 
503  //-- EMULATE ARP --------------------------------
504  pEmulateArp(
505  ssIPTX_ARP_LookupReq,
506  ssARP_IPTX_LookupRep,
507  myMacAddress,
508  myIp4Address,
509  mySubNetMask,
510  myGatewayAddr);
511 
512  //-- READ FROM STREAM AND WRITE TO FILE -----------
513  AxisEth axisEth;
514  if (!(ssIPTX_L2MUX_Data.empty())) {
515  ssIPTX_L2MUX_Data.read(axisEth);
516  if (not writeAxisRawToFile(axisEth, outFileStream)) {
517  nrErr++;
518  }
519  else {
520  nrIPTX_L2MUX_Chunks++;
521  nrIPTX_L2MUX_Bytes += axisEth.getLen();
522  if (axisEth.getLE_TLast()) {
523  nrIPTX_L2MUX_Frames++;
524  }
525  }
526  }
527 
528  tbRun--;
529  stepSim();
530  }
531 
532  //------------------------------------------------------
533  //-- CLOSE DUT OUTPUT TRAFFIC FILE
534  //------------------------------------------------------
535  outFileStream.close();
536 
537  printInfo(THIS_NAME, "############################################################################\n");
538  printInfo(THIS_NAME, "## TESTBENCH 'test_iptx' ENDS HERE ##\n");
539  printInfo(THIS_NAME, "############################################################################\n");
540  stepSim();
541 
542  //---------------------------------------------------------------
543  //-- COMPARE OUTPUT DAT and GOLD STREAMS
544  //---------------------------------------------------------------
545  int res = myDiffTwoFiles(std::string(ofsL2MUX_Data_FileName),
546  std::string(ofsL2MUX_Gold_FileName));
547  if (res) {
548  printError(THIS_NAME, "File \'%s\' does not match \'%s\' (rc=%d).\n", \
549  ofsL2MUX_Data_FileName.c_str(), ofsL2MUX_Gold_FileName.c_str(), res);
550  nrErr += 1;
551  }
552 
553  //---------------------------------------------------------------
554  //-- PRINT TESTBENCH STATUS
555  //---------------------------------------------------------------
556  printf("\n\n");
557  printInfo(THIS_NAME, "This testbench was executed with the following test-file: \n");
558  printInfo(THIS_NAME, "\t==> %s\n\n", argv[1]);
559 
560  if (nrErr) {
561  printError(THIS_NAME, "###########################################################\n");
562  printError(THIS_NAME, "#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
563  printError(THIS_NAME, "###########################################################\n\n");
564 
565  printInfo(THIS_NAME, "FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
566  }
567  else {
568  printInfo(THIS_NAME, "#############################################################\n");
569  printInfo(THIS_NAME, "#### SUCCESSFUL END OF TEST ####\n");
570  printInfo(THIS_NAME, "#############################################################\n");
571  }
572 
573  return nrErr;
574 
575 }
576 
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
int getLen() const
Definition: AxisRaw.hpp:411
bool isValid() const
Definition: AxisRaw.hpp:434
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
Class ETHERNET Frame.
Definition: SimEthFrame.hpp:55
bool writeToDatFile(ofstream &outFileStream)
Dump this Ethernet frame as raw AxisEth chunks into a file.
void setMacDestinAddress(EthAddr addr)
bool addPayload(SimArpPacket arpPkt)
Add data payload to this frame from an ARP packet.
void setTypeLength(EthTypeLen typLen)
void setMacSourceAddress(EthAddr addr)
Class IPv4 Packet for simulation.
bool tcpVerifyChecksum()
Recalculate the TCP checksum and compare it with the one embedded into the segment.
bool isWellFormed(const char *callerName, bool checkIp4TotLen=true, bool checkIp4HdrCsum=true, bool checkUdpLen=true, bool checkLy4Csum=true)
Checks if the IP header and embedded protocol fields are properly set.
Ip4Addr getIpSourceAddress()
void pushChunk(AxisIp4 ip4Chunk)
Ip4HdrCsum getIpHeaderChecksum()
bool udpVerifyChecksum()
Recalculate the UDP checksum and compare it with the one embedded into the datagram.
Ip4HdrCsum reCalculateIpHeaderChecksum()
Recalculate the IPv4 header checksum of a packet.
Ip4Addr getIpDestinationAddress()
unsigned int gSimCycCnt
Definition: tb_nal.cpp:150
bool gTraceEvent
Definition: tb_nal.cpp:151
bool gFatalError
Definition: tb_nal.cpp:152
#define TB_STARTUP_DELAY
Definition: test_arp.hpp:53
#define TB_GRACE_TIME
Definition: test_arp.hpp:54
#define TB_MAX_SIM_CYCLES
Definition: test_arp.hpp:52
unsigned int gMaxSimCycles
Definition: test_arp.hpp:69
int main(int argc, char *argv[])
Main function.
Definition: test_iptx.cpp:368
#define TRACE_CGF
Definition: test_iptx.cpp:42
void pEmulateArp(stream< Ip4Addr > &siIPTX_LookupReq, stream< ArpLkpReply > &soIPTX_LookupRep, EthAddr piMacAddress, Ip4Addr piIp4Address, Ip4Addr piSubNetMask, Ip4Addr piGatewayAddr)
Emulate the behavior of the Address Resolution Process (ARP).
Definition: test_iptx.cpp:72
void stepSim()
Increment the simulation counter.
Definition: test_iptx.cpp:51
void iptx_top_wrap(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisIp4 > &siL3MUX_Data, stream< AxisEth > &soL2MUX_Data, stream< Ip4Addr > &soARP_LookupReq, stream< ArpLkpReply > &siARP_LookupRep)
A wrapper for the Toplevel of IP the IP Transmitter Handler (IPTX).
Definition: test_iptx.cpp:328
int createGoldenFile(string inpDAT_FileName, string outDAT_GoldName, EthAddr myMacAddress, Ip4Addr myIp4Address, Ip4Addr mySubNetMask, Ip4Addr myGatewayAddr)
Create the golden reference file from an input test file.
Definition: test_iptx.cpp:138
#define THIS_NAME
Definition: test_iptx.cpp:39
#define DEBUG_LEVEL
Definition: test_iptx.cpp:46
#define TRACE_ARP
Definition: test_iptx.cpp:43
void iptx_top(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisRaw > &siL3MUX_Data, stream< AxisRaw > &soL2MUX_Data, stream< Ip4Addr > &soARP_LookupReq, stream< ArpLkpReply > &siARP_LookupRep)
Top of IP Transmitter Handler (IPTX)
Definition: iptx.cpp:676
bool isDatFile(string fileName)
Checks if a file has a ".dat" extension.
Definition: SimNtsUtils.cpp:52
bool writeAxisRawToFile(AxisRaw &axisRaw, ofstream &outFileStream)
Dump an Axis raw data chunk to a file.
bool readTbParamFromFile(const string paramName, const string datFile, unsigned int &paramVal)
Retrieve a testbench parameter from a DAT file.
int myDiffTwoFiles(string dataFileName, string goldFileName)
Compares 2 files line-by-line, up to length of the 2nd file.
bool readAxisRawFromFile(AxisRaw &axisRaw, ifstream &inpFileStream)
Retrieve an Axis raw data chunk from a file.
#define IP4_PROT_ICMP
Definition: nts_types.hpp:183
#define NTS_KO
Definition: nts_types.hpp:56
ap_uint< 48 > EthAddr
Definition: AxisEth.hpp:120
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
#define IP4_PROT_UDP
Definition: nts_types.hpp:185
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
ap_uint< 16 > Ip4HdrCsum
Definition: AxisIp4.hpp:165
void pAxisRawCast(hls::stream< TypeIn > &si, hls::stream< TypeOut > &so)
AxisRaw cast - Casts an AxisRaw stream to/from an AxisRaw derived class.
Definition: AxisRaw.hpp:148
#define IP4_PROT_TCP
Definition: nts_types.hpp:184
#define NTS_OK
Definition: nts_types.hpp:55
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
void printIp4Addr(const char *callerName, const char *message, Ip4Addr ip4Addr)
Print an IPv4 address prepended with a message (used for debugging).
Definition: nts_utils.cpp:205
#define printWarn(callerName, format,...)
A macro to print a warning message.
Definition: nts_utils.hpp:182
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
Definition: nts_utils.hpp:208
#define TLAST
Definition: AxisRaw.hpp:116
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.
Definition: uppercase.cpp:335
out
Definition: test.py:12
: Testbench for the IP Transmitter packet handler (IPTX).