cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_triangle_app.cpp File Reference
#include <stdio.h>
#include <hls_stream.h>
#include "../src/triangle_app.hpp"
Include dependency graph for test_triangle_app.cpp:

Go to the source code of this file.

Macros

#define OK   true
 
#define KO   false
 
#define VALID   true
 
#define UNVALID   false
 
#define DEBUG_TRACE   true
 
#define ENABLED   (ap_uint<1>)1
 
#define DISABLED   (ap_uint<1>)0
 

Functions

stream< UdpWordsSHL_Uaf_Data ("sSHL_Uaf_Data")
 
stream< UdpWordsUAF_Shl_Data ("sUAF_Shl_Data")
 
stream< NetworkMetaStreamsiUdp_meta ("siUdp_meta")
 
stream< NetworkMetaStreamsoUdp_meta ("soUdp_meta")
 
void stepDut ()
 Run a single iteration of the DUT model. More...
 
bool setInputDataStream (stream< UdpWord > &sDataStream, const string dataStreamName, const string inpFileName)
 Initialize an input data stream from a file. More...
 
bool readDataStream (stream< UdpWord > &sDataStream, UdpWord *udpWord)
 Read data from a stream. More...
 
bool dumpDataToFile (UdpWord *udpWord, ofstream &outFileStream)
 Dump a data word to a file. More...
 
bool getOutputDataStream (stream< UdpWord > &sDataStream, const string dataStreamName, const string outFileName)
 Fill an output file with data from an output stream. More...
 
int main ()
 

Variables

ap_uint< 1 > piSHL_This_MmioPostPktEn
 
ap_uint< 1 > piSHL_This_MmioCaptPktEn
 
ap_uint< 32 > s_udp_rx_ports = 0x0
 
ap_uint< 32 > node_rank
 
ap_uint< 32 > size
 
int simCnt
 

Macro Definition Documentation

◆ DEBUG_TRACE

#define DEBUG_TRACE   true

Definition at line 40 of file test_triangle_app.cpp.

◆ DISABLED

#define DISABLED   (ap_uint<1>)0

Definition at line 43 of file test_triangle_app.cpp.

◆ ENABLED

#define ENABLED   (ap_uint<1>)1

Definition at line 42 of file test_triangle_app.cpp.

◆ KO

#define KO   false

Definition at line 37 of file test_triangle_app.cpp.

◆ OK

#define OK   true

Definition at line 36 of file test_triangle_app.cpp.

◆ UNVALID

#define UNVALID   false

Definition at line 39 of file test_triangle_app.cpp.

◆ VALID

#define VALID   true

Definition at line 38 of file test_triangle_app.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 222 of file test_triangle_app.cpp.

222  {
223 
224  //------------------------------------------------------
225  //-- TESTBENCH LOCAL VARIABLES
226  //------------------------------------------------------
227  int nrErr = 0;
228 
229  printf("#####################################################\n");
230  printf("## TESTBENCH STARTS HERE ##\n");
231  printf("#####################################################\n");
232 
233  simCnt = 0;
234  nrErr = 0;
235 
236  //------------------------------------------------------
237  //-- STEP-1.1 : CREATE TRAFFIC AS INPUT STREAMS
238  //------------------------------------------------------
239  if (nrErr == 0) {
240  if (!setInputDataStream(sSHL_Uaf_Data, "sSHL_Uaf_Data", "ifsSHL_Uaf_Data.dat")) {
241  printf("### ERROR : Failed to set input data stream \"sSHL_Uaf_Data\". \n");
242  nrErr++;
243  }
244 
245  //there are 2 streams from the the App to the Role
247  siUdp_meta.write(NetworkMetaStream(tmp_meta));
248  siUdp_meta.write(NetworkMetaStream(tmp_meta));
249  //set correct node_rank and size
250  node_rank = 1;
251  size = 3;
252  }
253 
254  //------------------------------------------------------
255  //-- STEP-1.2 : SET THE PASS-THROUGH MODE
256  //------------------------------------------------------
257  //piSHL_This_MmioEchoCtrl.write(ECHO_PATH_THRU);
258  //[TODO] piSHL_This_MmioPostPktEn.write(DISABLED);
259  //[TODO] piSHL_This_MmioCaptPktEn.write(DISABLED);
260 
261  //------------------------------------------------------
262  //-- STEP-2 : MAIN TRAFFIC LOOP
263  //------------------------------------------------------
264  while (!nrErr) {
265 
266  if (simCnt < 25)
267  {
268  stepDut();
269 
270  if(simCnt > 2)
271  {
272  assert(s_udp_rx_ports == 0x1);
273  }
274 
275  //if( !soUdp_meta.empty())
276  //{
277  // NetworkMetaStream tmp_meta = soUdp_meta.read();
278  // printf("NRC received NRCmeta stream from node_rank %d.\n", (int) tmp_meta.tdata.src_rank);
279  //}
280 
281 
282  } else {
283  printf("## End of simulation at cycle=%3d. \n", simCnt);
284  break;
285  }
286 
287  } // End: while()
288 
289  //-------------------------------------------------------
290  //-- STEP-3 : DRAIN AND WRITE OUTPUT FILE STREAMS
291  //-------------------------------------------------------
292  //---- UAF-->SHELL Data ----
293  if (!getOutputDataStream(sUAF_Shl_Data, "sUAF_Shl_Data", "ofsUAF_Shl_Data.dat"))
294  {
295  nrErr++;
296  }
297  //---- UAF-->SHELL META ----
298  if( !soUdp_meta.empty())
299  {
300  int i = 0;
301  while( !soUdp_meta.empty())
302  {
303  i++;
304  NetworkMetaStream tmp_meta = soUdp_meta.read();
305  printf("NRC received NRCmeta stream to rank %d.\n", (int) tmp_meta.tdata.dst_rank);
306  //assert(tmp_meta.tdata.src_rank == node_rank); //is not relevant
307  //ensure forwarding behavior
308  assert(tmp_meta.tdata.dst_rank == ((node_rank + 1) % size));
309  }
310  assert(i == 2);
311  } else {
312  printf("Error No metadata received...\n");
313  nrErr++;
314  }
315 
316  //------------------------------------------------------
317  //-- STEP-4 : COMPARE INPUT AND OUTPUT FILE STREAMS
318  //------------------------------------------------------
319  int rc1 = system("diff --brief -w -i -y ../../../../test/ofsUAF_Shl_Data.dat \
320  ../../../../test/ifsSHL_Uaf_Data.dat");
321  if (rc1)
322  printf("## Error : File \'ofsUAF_Shl_Data.dat\' does not match \'ifsSHL_Uaf_Data.dat\'.\n");
323 
324  nrErr += rc1;
325 
326  printf("#####################################################\n");
327  if (nrErr)
328  printf("## ERROR - TESTBENCH FAILED (RC=%d) !!! ##\n", nrErr);
329  else
330  printf("## SUCCESSFULL END OF TESTBENCH (RC=0) ##\n");
331 
332  printf("#####################################################\n");
333 
334  return(nrErr);
335 }
#define DEFAULT_RX_PORT
Definition: nal.hpp:139
bool getOutputDataStream(stream< UdpWord > &sDataStream, const string dataStreamName, const string outFileName)
Fill an output file with data from an output stream.
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.
NetworkMeta tdata
Definition: network.hpp:109
NodeId dst_rank
Definition: network.hpp:95
stream< NetworkMetaStream > siUdp_meta("siUdp_meta")
ap_uint< 32 > size
stream< NetworkMetaStream > soUdp_meta("soUdp_meta")
int simCnt
stream< UdpWord > sUAF_Shl_Data("sUAF_Shl_Data")
stream< UdpWord > sSHL_Uaf_Data("sSHL_Uaf_Data")
ap_uint< 32 > s_udp_rx_ports
ap_uint< 32 > node_rank
Here is the call graph for this function:

◆ siUdp_meta()

stream<NetworkMetaStream> siUdp_meta ( "siUdp_meta"  )
Here is the caller graph for this function:

◆ soUdp_meta()

stream<NetworkMetaStream> soUdp_meta ( "soUdp_meta"  )
Here is the caller graph for this function:

◆ sSHL_Uaf_Data()

stream<UdpWord> sSHL_Uaf_Data ( "sSHL_Uaf_Data"  )
Here is the caller graph for this function:

◆ sUAF_Shl_Data()

stream<UdpWord> sUAF_Shl_Data ( "sUAF_Shl_Data"  )
Here is the caller graph for this function:

Variable Documentation

◆ node_rank

ap_uint<32> node_rank

Definition at line 60 of file test_triangle_app.cpp.

◆ piSHL_This_MmioCaptPktEn

ap_uint<1> piSHL_This_MmioCaptPktEn

Definition at line 52 of file test_triangle_app.cpp.

◆ piSHL_This_MmioPostPktEn

ap_uint<1> piSHL_This_MmioPostPktEn

Definition at line 51 of file test_triangle_app.cpp.

◆ s_udp_rx_ports

ap_uint<32> s_udp_rx_ports = 0x0

Definition at line 57 of file test_triangle_app.cpp.

◆ simCnt

int simCnt

Definition at line 66 of file test_triangle_app.cpp.

◆ size

ap_uint<32> size

Definition at line 61 of file test_triangle_app.cpp.