cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_upper_lower_app.cpp File Reference
#include <stdio.h>
#include <hls_stream.h>
#include "../src/upper_lower_app.hpp"
Include dependency graph for test_upper_lower_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 > cluster_size
 
int simCnt
 

Macro Definition Documentation

◆ DEBUG_TRACE

#define DEBUG_TRACE   true

Definition at line 39 of file test_upper_lower_app.cpp.

◆ DISABLED

#define DISABLED   (ap_uint<1>)0

Definition at line 42 of file test_upper_lower_app.cpp.

◆ ENABLED

#define ENABLED   (ap_uint<1>)1

Definition at line 41 of file test_upper_lower_app.cpp.

◆ KO

#define KO   false

Definition at line 36 of file test_upper_lower_app.cpp.

◆ OK

#define OK   true

Definition at line 35 of file test_upper_lower_app.cpp.

◆ UNVALID

#define UNVALID   false

Definition at line 38 of file test_upper_lower_app.cpp.

◆ VALID

#define VALID   true

Definition at line 37 of file test_upper_lower_app.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 221 of file test_upper_lower_app.cpp.

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

◆ cluster_size

ap_uint<32> cluster_size

Definition at line 60 of file test_upper_lower_app.cpp.

◆ node_rank

ap_uint<32> node_rank

Definition at line 59 of file test_upper_lower_app.cpp.

◆ piSHL_This_MmioCaptPktEn

ap_uint<1> piSHL_This_MmioCaptPktEn

Definition at line 51 of file test_upper_lower_app.cpp.

◆ piSHL_This_MmioPostPktEn

ap_uint<1> piSHL_This_MmioPostPktEn

Definition at line 50 of file test_upper_lower_app.cpp.

◆ s_udp_rx_ports

ap_uint<32> s_udp_rx_ports = 0x0

Definition at line 56 of file test_upper_lower_app.cpp.

◆ simCnt

int simCnt

Definition at line 65 of file test_upper_lower_app.cpp.