cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
Uppercase Testbench

This is a subgroup of Uppercase accelerated function with only testbench-related functions/classes. More...

Collaboration diagram for Uppercase Testbench:

Files

file  uppercase_host_fwd_tb.cpp
 Testbench for Uppercase userspace application for cF (x86, ppc64).
 
file  uppercase_host_fwd_tb.cpp
 Testbench for Uppercase userspace application for cF (x86, ppc64).
 
file  test_uppercase.cpp
 : Testbench for Uppercase.
 
file  test_uppercase.cpp
 : Testbench for Uppercase.
 

Macros

#define MAX_PACKETS_FOR_TB   10
 
#define THIS_NAME   "TB"
 
#define TRACE_OFF   0x0000
 
#define TRACE_URIF   1 << 1
 
#define TRACE_UAF   1 << 2
 
#define TRACE_MMIO   1 << 3
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_ALL)
 
#define OK   true
 
#define KO   false
 
#define VALID   true
 
#define UNVALID   false
 
#define DEBUG_TRACE   true
 
#define DEBUG_MULTI_RUNS   True
 
#define TB_MULTI_RUNS_ITERATIONS   2
 
#define ENABLED   (ap_uint<1>)1
 
#define DISABLED   (ap_uint<1>)0
 
#define THIS_NAME   "TB"
 
#define TRACE_OFF   0x0000
 
#define TRACE_URIF   1 << 1
 
#define TRACE_UAF   1 << 2
 
#define TRACE_MMIO   1 << 3
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_ALL)
 
#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

bool findCharNullPos (char *str)
 
int main (int argc, char *argv[])
 
unsigned int writeStructToConfFile (const char *fname, varin *instruct)
 Fill an output file with data from an image. More...
 
stream< UdpWordsSHL_Uaf_Data ("sSHL_Uaf_Data")
 
stream< UdpWordsUAF_Shl_Data ("sUAF_Shl_Data")
 
stream< UdpWordimage_stream_from_uppercase ("image_stream_from_uppercase")
 
stream< NetworkMetaStreamsiUdp_meta ("siUdp_meta")
 
stream< NetworkMetaStreamsoUdp_meta ("soUdp_meta")
 
void stepDut ()
 Run a single iteration of the DUT model. More...
 
int main (int argc, char **argv)
 Main testbench of Hrris. More...
 

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
 
unsigned int simCnt
 
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
 
unsigned int simCnt
 

Detailed Description

This is a subgroup of Uppercase accelerated function with only testbench-related functions/classes.

Macro Definition Documentation

◆ DEBUG_LEVEL [1/2]

#define DEBUG_LEVEL   (TRACE_ALL)

Definition at line 53 of file test_uppercase.cpp.

◆ DEBUG_LEVEL [2/2]

#define DEBUG_LEVEL   (TRACE_ALL)

Definition at line 52 of file test_uppercase.cpp.

◆ DEBUG_MULTI_RUNS

#define DEBUG_MULTI_RUNS   True

Definition at line 64 of file test_uppercase.cpp.

◆ DEBUG_TRACE [1/2]

#define DEBUG_TRACE   true

Definition at line 63 of file test_uppercase.cpp.

◆ DEBUG_TRACE [2/2]

#define DEBUG_TRACE   true

Definition at line 62 of file test_uppercase.cpp.

◆ DISABLED [1/2]

#define DISABLED   (ap_uint<1>)0

Definition at line 68 of file test_uppercase.cpp.

◆ DISABLED [2/2]

#define DISABLED   (ap_uint<1>)0

Definition at line 65 of file test_uppercase.cpp.

◆ ENABLED [1/2]

#define ENABLED   (ap_uint<1>)1

Definition at line 67 of file test_uppercase.cpp.

◆ ENABLED [2/2]

#define ENABLED   (ap_uint<1>)1

Definition at line 64 of file test_uppercase.cpp.

◆ KO [1/2]

#define KO   false

Definition at line 60 of file test_uppercase.cpp.

◆ KO [2/2]

#define KO   false

Definition at line 59 of file test_uppercase.cpp.

◆ MAX_PACKETS_FOR_TB

#define MAX_PACKETS_FOR_TB   10

Definition at line 48 of file uppercase_host_fwd_tb.cpp.

◆ OK [1/2]

#define OK   true

Definition at line 59 of file test_uppercase.cpp.

◆ OK [2/2]

#define OK   true

Definition at line 58 of file test_uppercase.cpp.

◆ TB_MULTI_RUNS_ITERATIONS

#define TB_MULTI_RUNS_ITERATIONS   2

Definition at line 65 of file test_uppercase.cpp.

◆ THIS_NAME [1/2]

#define THIS_NAME   "TB"

Definition at line 45 of file test_uppercase.cpp.

◆ THIS_NAME [2/2]

#define THIS_NAME   "TB"

Definition at line 44 of file test_uppercase.cpp.

◆ TRACE_ALL [1/2]

#define TRACE_ALL   0xFFFF

Definition at line 51 of file test_uppercase.cpp.

◆ TRACE_ALL [2/2]

#define TRACE_ALL   0xFFFF

Definition at line 50 of file test_uppercase.cpp.

◆ TRACE_MMIO [1/2]

#define TRACE_MMIO   1 << 3

Definition at line 50 of file test_uppercase.cpp.

◆ TRACE_MMIO [2/2]

#define TRACE_MMIO   1 << 3

Definition at line 49 of file test_uppercase.cpp.

◆ TRACE_OFF [1/2]

#define TRACE_OFF   0x0000

Definition at line 47 of file test_uppercase.cpp.

◆ TRACE_OFF [2/2]

#define TRACE_OFF   0x0000

Definition at line 46 of file test_uppercase.cpp.

◆ TRACE_UAF [1/2]

#define TRACE_UAF   1 << 2

Definition at line 49 of file test_uppercase.cpp.

◆ TRACE_UAF [2/2]

#define TRACE_UAF   1 << 2

Definition at line 48 of file test_uppercase.cpp.

◆ TRACE_URIF [1/2]

#define TRACE_URIF   1 << 1

Definition at line 48 of file test_uppercase.cpp.

◆ TRACE_URIF [2/2]

#define TRACE_URIF   1 << 1

Definition at line 47 of file test_uppercase.cpp.

◆ UNVALID [1/2]

#define UNVALID   false

Definition at line 62 of file test_uppercase.cpp.

◆ UNVALID [2/2]

#define UNVALID   false

Definition at line 61 of file test_uppercase.cpp.

◆ VALID [1/2]

#define VALID   true

Definition at line 61 of file test_uppercase.cpp.

◆ VALID [2/2]

#define VALID   true

Definition at line 60 of file test_uppercase.cpp.

Function Documentation

◆ findCharNullPos()

bool findCharNullPos ( char *  str)

Definition at line 91 of file uppercase_host_fwd_tb.cpp.

91  {
92  unsigned int len = strlen(str);
93  bool f = false;
94  for(unsigned int i=0; i<=len; i++) {
95  if(str[i]=='\0') {
96  printf("DEBUG: null character position: %d\n",i+1);
97  f = true;
98  }
99  }
100  if(f == false) {
101  printf("DEBUG: null character not found\n");
102  }
103  return f;
104 }
Here is the caller graph for this function:

◆ image_stream_from_uppercase()

stream< UdpWord > image_stream_from_uppercase ( "image_stream_from_uppercase"  )

◆ main() [1/2]

int main ( int  argc,
char **  argv 
)

Main testbench of Hrris.

Returns
0 upon success, nrErr else.

Definition at line 135 of file test_uppercase.cpp.

135  {
136 
137  //------------------------------------------------------
138  //-- TESTBENCH LOCAL VARIABLES
139  //------------------------------------------------------
140  int nrErr = 0;
141 
142  printf("#####################################################\n");
143  printf("## TESTBENCH STARTS HERE ##\n");
144  printf("#####################################################\n");
145 
146  simCnt = 0;
147  nrErr = 0;
148 
149  if (argc != 2) {
150  printf("Usage : %s <input string> , provided %d\n", argv[0], argc);
151  return -1;
152  }
153 
154  string tmp_string= argv[1];
155  string strInput;
156 
157  //clean the corners if make or other utilities insert this weird ticks at the beginning of the string
158  if(isCornerPresent(tmp_string,"'") or isCornerPresent(tmp_string,"`") or isCornerPresent(tmp_string,"\"") ){
159  tmp_string = tmp_string.substr(1,tmp_string.length()-2);
160  }
161 
162  strInput = tmp_string;
163  if (!strInput.length()) {
164  printf("ERROR: Empty string provided. Aborting...\n");
165  return -1;
166  }
167  else {
168  printf("Succesfully loaded string ... %s\n", argv[1]);
169  // Ensure that the selection of MTU is a multiple of 8 (Bytes per transaction)
170  assert(PACK_SIZE % 8 == 0);
171  }
172 
173  //------------------------------------------------------
174  //-- TESTBENCH LOCAL VARIABLES FOR UPPERCASE
175  //------------------------------------------------------
176  unsigned int sim_time = 2 * CEIL(strInput.length(), 8) + 10;
177  unsigned int tot_trasnfers = (CEIL(strInput.length(), PACK_SIZE));
178  char *charOutput = (char*)malloc(strInput.length() * sizeof(char));
179  char *charInput = (char*)malloc(strInput.length() * sizeof(char));
180  if (!charOutput || !charInput) {
181  printf("ERROR: Cannot allocate memory for output string. Aborting...\n");
182  return -1;
183  }
184 
185 
186  //------------------------------------------------------
187  //-- STEP-1.1 : CREATE MEMORY FOR OUTPUT IMAGES
188  //------------------------------------------------------
189  if (!dumpStringToFile(strInput, "ifsSHL_Uaf_Data.dat", simCnt)) {
190  nrErr++;
191  }
192  //std::string strGold = createUppercaseGoldenOutput(strInput);
193  //if (!dumpStringToFile(strGold, "verify_UAF_Shl_Data.dat", simCnt)){
194  // nrErr++;
195  //}
200  #ifdef DEBUG_MULTI_RUNS // test if the HLS kernel has reinit issues with streams leftovers or other stuffs
201  for(int iterations=0; iterations < TB_MULTI_RUNS_ITERATIONS; iterations++){
202  #endif //DEBUG_MULTI_RUNS
203  #ifdef ENABLE_DDR
204  for(int i=0; i < MEMORY_LINES_512; i++){
205  lcl_mem0[i]=0;
206  lcl_mem1[i]=0;
207  }
208  #endif//ENABLE_DDR
209 
210  //------------------------------------------------------
211  //-- STEP-2.1 : CREATE TRAFFIC AS INPUT STREAMS
212  //------------------------------------------------------
213  if (nrErr == 0) {
214  if (!setInputDataStream(sSHL_Uaf_Data, "sSHL_Uaf_Data", "ifsSHL_Uaf_Data.dat", simCnt)) {
215  printf("### ERROR : Failed to set input data stream \"sSHL_Uaf_Data\". \n");
216  nrErr++;
217  }
218 
219  //there are tot_trasnfers streams from the the App to the Role
221  for (unsigned int i=0; i<tot_trasnfers; i++) {
222  siUdp_meta.write(NetworkMetaStream(tmp_meta));
223  }
224  //set correct node_rank and cluster_size
225  node_rank = 1;
226  cluster_size = 2;
227  }
228 
229  //------------------------------------------------------
230  //-- STEP-2.2 : SET THE PASS-THROUGH MODE
231  //------------------------------------------------------
232  //piSHL_This_MmioEchoCtrl.write(ECHO_PATH_THRU);
233  //[TODO] piSHL_This_MmioPostPktEn.write(DISABLED);
234  //[TODO] piSHL_This_MmioCaptPktEn.write(DISABLED);
235 
236  //------------------------------------------------------
237  //-- STEP-3 : MAIN TRAFFIC LOOP
238  //------------------------------------------------------
239  while (!nrErr) {
240 
241  // Keep enough simulation time for sequntially executing the FSMs of the main 3 functions
242  // (Rx-Tx)
243  if (simCnt < sim_time)
244  {
245  stepDut();
246 
247  if(simCnt > 2)
248  {
249  assert(s_udp_rx_ports == 0x1);
250  }
251 
252  //if( !soUdp_meta.empty())
253  //{
254  // NetworkMetaStream tmp_meta = soUdp_meta.read();
255  // printf("NRC received NRCmeta stream from node_rank %d.\n", (int) tmp_meta.tdata.src_rank);
256  //}
257 
258 
259  } else {
260  printf("## End of simulation at cycle=%3d. \n", simCnt);
261  break;
262  }
263 
264  } // End: while()
265 
266  //-------------------------------------------------------
267  //-- STEP-4 : DRAIN AND WRITE OUTPUT FILE STREAMS
268  //-------------------------------------------------------
269  //---- UAF-->SHELL Data ----
270  if (!getOutputDataStream(sUAF_Shl_Data, "sUAF_Shl_Data", "ofsUAF_Shl_Data.dat", simCnt))
271  {
272  nrErr++;
273  }
274  //---- UAF-->SHELL META ----
275  if( !soUdp_meta.empty())
276  {
277  unsigned int i = 0;
278  while( !soUdp_meta.empty())
279  {
280  i++;
281  NetworkMetaStream tmp_meta = soUdp_meta.read();
282  printf("NRC received NRCmeta stream from rank %d to rank %d.\n", (int) tmp_meta.tdata.src_rank, (int) tmp_meta.tdata.dst_rank);
283  assert(tmp_meta.tdata.src_rank == node_rank);
284  //ensure forwarding behavior
285  assert(tmp_meta.tdata.dst_rank == ((tmp_meta.tdata.src_rank + 1) % cluster_size));
286  }
287  assert(i == tot_trasnfers);
288  }
289  else {
290  printf("Error No metadata received...\n");
291  nrErr++;
292  }
293 
294  //-------------------------------------------------------
295  //-- STEP-5 : FROM THE OUTPUT FILE CREATE AN ARRAY
296  //-------------------------------------------------------
297  if (!dumpFileToString("ifsSHL_Uaf_Data.dat", charInput, simCnt)) {
298  printf("### ERROR : Failed to set string from file \"ofsUAF_Shl_Data.dat\". \n");
299  nrErr++;
300  }
301  printf("Input string : ");
302  for (unsigned int i = 0; i < strInput.length(); i++)
303  printf("%c", charInput[i]);
304  printf("\n");
305  if (!dumpFileToString("ofsUAF_Shl_Data.dat", charOutput, simCnt)) {
306  printf("### ERROR : Failed to set string from file \"ofsUAF_Shl_Data.dat\". \n");
307  nrErr++;
308  }
309  __file_write("./hls_out.txt", charOutput, strInput.length());
310  printf("Output string: ");
311  for (unsigned int i = 0; i < strInput.length(); i++)
312  printf("%c", charOutput[i]);
313  printf("\n");
314 
315  //------------------------------------------------------
316  //-- STEP-6 : COMPARE INPUT 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  cout<< endl << " End the TB with iteration " << iterations << endl << endl;
328  nrErr += rc1;
329 
330  printf("#####################################################\n");
331  if (nrErr)
332  {
333  printf("## ERROR - TESTBENCH FAILED (RC=%d) !!! ##\n", nrErr);
334  } else {
335  printf("## SUCCESSFULL END OF TESTBENCH (RC=0) ##\n");
336  }
337  printf("#####################################################\n");
338 
339  simCnt = 0;//reset sim counter
340  nrErr=0;
341  #ifdef DEBUG_MULTI_RUNS
342  }
343  #endif//DEBUG_MULTI_RUNS
344 
345  //free dynamic memory
346  if(charOutput != NULL){
347  free(charOutput);
348  charOutput = NULL;
349  }
350  if(charInput != NULL){
351  free(charInput);
352  charInput = NULL;
353  }
354  return(nrErr);
355 }
bool dumpFileToString(const std::string inpFileName, std::string strOutput, int simCnt)
Initialize an input data stream from a file.
bool isCornerPresent(std::string str, std::string corner)
Check the presence of a given corner value at the begin and the end of a string.
bool dumpStringToFile(std::string s, const std::string outFileName, int simCnt)
Initialize an input data stream from a file.
membus_t lcl_mem0[16384]
membus_t lcl_mem1[16384]
#define MEMORY_LINES_512
#define PACK_SIZE
Definition: config.h:51
#define CEIL(a, b)
Definition: config.h:37
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
unsigned int simCnt
stream< NetworkMetaStream > siUdp_meta("siUdp_meta")
stream< NetworkMetaStream > soUdp_meta("soUdp_meta")
#define TB_MULTI_RUNS_ITERATIONS
stream< UdpWord > sUAF_Shl_Data("sUAF_Shl_Data")
void stepDut()
Run a single iteration of the DUT model.
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
NetworkMeta tdata
Definition: network.hpp:109
NodeId dst_rank
Definition: network.hpp:95
NodeId src_rank
Definition: network.hpp:97
Here is the call graph for this function:

◆ main() [2/2]

int main ( int  argc,
char *  argv[] 
)

Main testbench for the user-application for Uppercase on host. Server

Returns
O on success, 1 on fail

Main testbench for the user-application for MCEuropeanEngine on host. Server

Returns
O on success, 1 on fail

Definition at line 111 of file uppercase_host_fwd_tb.cpp.

111  {
112 
113  if ((argc < 2) || (argc > 4)) { // Test for correct number of parameters
114  cerr << "Usage: " << argv[0] << " <Server Port> <optional simulation mode> <optional >" << endl;
115  cerr << "<optional simulation mode> : 0 - fcsim, 2 - csim, 3 - csynth + cosim, 4 - memchecksim, 5 - kcachegrind" << endl;
116  cerr << "<optional loop> : 0 - executed once, 1 - executed continuously" << endl;
117  exit(1);
118  }
119 
120  unsigned short servPort = atoi(argv[1]); // First arg: local port
121  unsigned int num_batch = 0;
122  string clean_cmd, synth_cmd;;
123  unsigned int run_loop = 0;
124 
125  if (argc == 4) {
126  run_loop = atoi(argv[3]);
127  if (run_loop > 1) {
128  cerr << "ERROR: Not valid loop option provided: " << argv[3] << " . Choose either 0 or 1. Aborting..." << endl;
129  exit(EXIT_FAILURE);
130  }
131  }
132 
133  try {
134  #if NET_TYPE == udp
135  UDPSocket sock(servPort);
136  #else
137  TCPServerSocket servSock(servPort); // Server Socket object
138  TCPSocket *servsock = servSock.accept(); // Wait for a client to connect
139  #endif
140  char buffer[BUF_LEN]; // Buffer for echo string
141  unsigned int recvMsgSize; // Size of received message
142  string sourceAddress; // Address of datagram source
143  unsigned short sourcePort; // Port of datagram source
144 
145  #if NET_TYPE == tcp
146  // TCP client handling
147  cout << "Handling client ";
148  try {
149  cout << servsock->getForeignAddress() << ":";
150  } catch (SocketException e) {
151  cerr << "Unable to get foreign address" << endl;
152  }
153  try {
154  cout << servsock->getForeignPort();
155  } catch (SocketException e) {
156  cerr << "Unable to get foreign port" << endl;
157  }
158  cout << endl;
159  #endif
160 
161  // Loop over a number of tb proxy times (to allow host sw to test several times)
162  do {
163  // RX Step
164  clock_t last_cycle_rx = clock();
165 
166  // Block until receive message from a client
167 
168  int input_string_total_len = 0;
169  //int receiving_now = PACK_SIZE;
170  int total_pack = 0;
171  int bytes_in_last_pack;
172  bool msg_received = false;
173  cout << " ___________________________________________________________________ " << endl;
174  cout << "/ \\" << endl;
175  cout << "INFO: Proxy tb batch # " << ++num_batch << endl;
176  //char * longbuf = new char[PACK_SIZE * total_pack];
177  char * longbuf = (char *) malloc (PACK_SIZE * MAX_PACKETS_FOR_TB * sizeof(char));
178 
179  // RX Loop
180  for (int i = 0; msg_received != true; i++, total_pack++) {
181  #if NET_TYPE == udp
182  recvMsgSize = sock.recvFrom(buffer, BUF_LEN, sourceAddress, sourcePort);
183  #else
184  recvMsgSize = servsock->recv(buffer, receiving_now);
185  #endif
186  input_string_total_len += recvMsgSize;
187  bytes_in_last_pack = recvMsgSize;
188  bool nullcharfound = findCharNullPos(buffer);
189  //printf("DEBUG: i=%d recvMsgSize=%u strlen(buffer)=%u nullcharfound=%u\n", i, recvMsgSize, strlen(buffer), nullcharfound);
190  memcpy( & longbuf[i * PACK_SIZE], buffer, recvMsgSize);
191  if (nullcharfound != true) {
192  cout << "INFO: The string is not entirely fit in packet " << total_pack << endl;
193  }
194  else {
195  msg_received = true;
196  }
197  }
198 
199  cout << "INFO: Received packet from " << sourceAddress << ":" << sourcePort << endl;
200  //cout << "DEBUG: longbuf=" << longbuf << endl;
201  string input_string = longbuf;
202  if (input_string.length() == 0) {
203  cerr << "ERROR: received an empty string! Aborting..." << endl;
204  return -1;
205  }
206 
207  // Select simulation mode, default fcsim
208  synth_cmd = " ";
209  string exec_cmd = "make fcsim -j 4";
210  string ouf_file = "../../../../../../ROLE/custom/hls/uppercase/uppercase_prj/solution1/fcsim/build/hls_out.txt";
211  if (argc >= 3) {
212  if (atoi(argv[2]) == 2) {
213  exec_cmd = "make csim";
214  ouf_file = "../../../../../../ROLE/custom/hls/uppercase/uppercase_prj/solution1/csim/build/hls_out.txt";
215  }
216  else if (atoi(argv[2]) == 3) {
217  synth_cmd = "make csynth && ";
218  exec_cmd = "make cosim";
219  ouf_file = "../../../../../../ROLE/custom/hls/uppercase/uppercase_prj/solution1/sim/wrapc_pc/build/hls_out.txt";
220  }
221  else if (atoi(argv[2]) == 4) {
222  exec_cmd = "make memchecksim";
223  ouf_file = "../../../../../../ROLE/custom/hls/uppercase/uppercase_prj/solution1/fcsim/build/hls_out.txt";
224  }
225  else if (atoi(argv[2]) == 5) {
226  exec_cmd = "make kcachegrind";
227  ouf_file = "../../../../../../ROLE/custom/hls/uppercase/uppercase_prj/solution1/fcsim/build/hls_out.txt";
228  }
229  } // Calling the actual TB over its typical makefile procedure, but passing the save file
230  // Skip the rebuilding phase on the 2nd run. However ensure that it's a clean recompile
231  // the first time.
232  clean_cmd = " ";
233  if (num_batch == 1) {
234  clean_cmd = "make clean && ";
235  }
236 
237  string str_command = "cd ../../../../../../ROLE/custom/hls/uppercase/ && " + clean_cmd + synth_cmd + "\
238  INPUT_STRING=" + input_string + " " + exec_cmd + " && \
239  cd ../../../../HOST/custom/uppercase/languages/cplusplus/build/ ";
240  const char *command = str_command.c_str();
241  cout << "Calling TB with command:" << command << endl;
242  system(command);
243 
244  ssize_t size = __file_size(ouf_file.c_str());
245  int rc = __file_read(ouf_file.c_str(), longbuf, size);
246  if (rc < 0) {
247  cerr << "ERROR: Cannot read file " << ouf_file << " . Aborting..."<< endl;
248  return -1;
249  }
250 
251  clock_t next_cycle_rx = clock();
252  double duration_rx = (next_cycle_rx - last_cycle_rx) / (double) CLOCKS_PER_SEC;
253  cout << "INFO: Effective FPS RX:" << (1 / duration_rx) << " \tkbps:" << (PACK_SIZE *
254  total_pack / duration_rx / 1024 * 8) << endl;
255  last_cycle_rx = next_cycle_rx;
256 
257 
258  // TX step
259  string out_string = longbuf;
260  if (out_string.length() == 0) {
261  cerr << "ERROR: Received empty string!" << endl;
262  return -1;
263  }
264  else {
265  cout << "INFO: Succesfully received string from TB : " << out_string << endl;
266  cout << "INFO: Will forward it back to host app ... total_pack=" << endl;
267  }
268 
269 
270  // TX Loop
271  unsigned int sending_now = PACK_SIZE;
272  clock_t last_cycle_tx = clock();
273  for (int i = 0; i < total_pack; i++) {
274  if ( i == total_pack - 1 ) {
275  sending_now = bytes_in_last_pack;
276  }
277  #if NET_TYPE == udp
278  sock.sendTo( & longbuf[i * PACK_SIZE], sending_now, sourceAddress, sourcePort);
279  #else
280  servsock->send( & longbuf[i * PACK_SIZE], sending_now);
281  #endif
282  }
283 
284  clock_t next_cycle_tx = clock();
285  double duration_tx = (next_cycle_tx - last_cycle_tx) / (double) CLOCKS_PER_SEC;
286  cout << "INFO: Effective FPS TX:" << (1 / duration_tx) << " \tkbps:" << (PACK_SIZE *
287  total_pack / duration_tx / 1024 * 8) << endl;
288  last_cycle_tx = next_cycle_tx;
289  free(longbuf);
290  cout << "\\___________________________________________________________________/" << endl;
291 
292  } while (run_loop == 1);
293 
294  #if NET_TYPE == tcp
295  delete servsock;
296  #endif
297  } catch (SocketException & e) {
298  cerr << e.what() << endl;
299  exit(1);
300  }
301  return 0;
302 }
#define BUF_LEN
Definition: config.h:54
#define MAX_PACKETS_FOR_TB
bool findCharNullPos(char *str)
def clock()
Definition: common.py:174
ap_uint< 32 > size
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:

◆ stepDut()

void stepDut ( )

Run a single iteration of the DUT model.

Returns
Nothing.

Definition at line 108 of file test_uppercase.cpp.

108  {
109  uppercase(
110  &node_rank,
111  &cluster_size,
114  siUdp_meta,
115  soUdp_meta,
117  #ifdef ENABLE_DDR
118  ,
119  lcl_mem0,
120  lcl_mem0
121  #endif
122  );
123  simCnt++;
124  //memcpy(lcl_mem1,lcl_mem0,MEMORY_LINES_512*sizeof(membus_t));
125  printf("[%4.4d] STEP DUT \n", simCnt);
126 }
#define ENABLE_DDR
Definition: memtest.hpp:42
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
Here is the call graph for this function:
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:

◆ writeStructToConfFile()

unsigned int writeStructToConfFile ( const char *  fname,
varin instruct 
)

Fill an output file with data from an image.

Parameters
[in]sDataStreamthe input image in xf::cv::Mat format.
[in]outFileNamethe name of the output file to write to.
Returns
OK if successful, otherwise KO.

Definition at line 97 of file mceuropeanengine_host_fwd_tb.cpp.

97  {
98 
99  if ((fname == NULL) || (instruct == NULL))
100  return -EINVAL;
101 
102  std::ofstream ifile(fname);
103 
104  //check to see that the file was opened correctly:
105  if (!ifile.is_open()) {
106  std::cerr << "There was a problem creating the output file!\n";
107  return -EIO;
108  }
109  unsigned int i, j;
110  for (i = 0, j = 0; i < sizeof(varin); i+=sizeof(DtUsed), j++) {
111  switch(j)
112  {
113  case 0:
114  ifile << instruct->loop_nm << endl;
115  break;
116  case 1:
117  ifile << instruct->seed << endl;
118  break;
119  case 2:
120  ifile << instruct->underlying << endl;
121  break;
122  case 3:
123  ifile << instruct->volatility << endl;
124  break;
125  case 4:
126  ifile << instruct->dividendYield << endl;
127  break;
128  case 5:
129  ifile << instruct->riskFreeRate << endl;
130  break;
131  case 6:
132  ifile << instruct->timeLength << endl;
133  break;
134  case 7:
135  ifile << instruct->strike << endl;
136  break;
137  case 8:
138  ifile << instruct->optionType << endl;
139  break;
140  case 9:
141  ifile << instruct->requiredTolerance << endl;
142  break;
143  case 10:
144  ifile << instruct->requiredSamples << endl;
145  break;
146  case 11:
147  ifile << instruct->timeSteps << endl;
148  break;
149  case 12:
150  ifile << instruct->maxSamples << endl;
151  break;
152  default:
153  break;
154  }
155  }
156  ifile.close();
157  return (i);
158 }
#define DtUsed
Definition: config.h:57
Definition: config.h:85
double dividendYield
Definition: config.h:90
DtUsedInt seed
Definition: config.h:87
DtUsedInt maxSamples
Definition: config.h:98
double riskFreeRate
Definition: config.h:91
double volatility
Definition: config.h:89
double requiredTolerance
Definition: config.h:95
DtUsedInt loop_nm
Definition: config.h:86
double underlying
Definition: config.h:88
DtUsedInt timeSteps
Definition: config.h:97
double strike
Definition: config.h:93
DtUsedInt requiredSamples
Definition: config.h:96
DtUsedInt optionType
Definition: config.h:94
double timeLength
Definition: config.h:92

Variable Documentation

◆ cluster_size [1/2]

ap_uint<32> cluster_size

Definition at line 89 of file test_uppercase.cpp.

◆ cluster_size [2/2]

ap_uint<32> cluster_size

Definition at line 86 of file test_uppercase.cpp.

◆ node_rank [1/2]

ap_uint<32> node_rank

Definition at line 88 of file test_uppercase.cpp.

◆ node_rank [2/2]

ap_uint<32> node_rank

Definition at line 85 of file test_uppercase.cpp.

◆ piSHL_This_MmioCaptPktEn [1/2]

ap_uint<1> piSHL_This_MmioCaptPktEn

Definition at line 78 of file test_uppercase.cpp.

◆ piSHL_This_MmioCaptPktEn [2/2]

ap_uint<1> piSHL_This_MmioCaptPktEn

Definition at line 75 of file test_uppercase.cpp.

◆ piSHL_This_MmioPostPktEn [1/2]

ap_uint<1> piSHL_This_MmioPostPktEn

Definition at line 77 of file test_uppercase.cpp.

◆ piSHL_This_MmioPostPktEn [2/2]

ap_uint<1> piSHL_This_MmioPostPktEn

Definition at line 74 of file test_uppercase.cpp.

◆ s_udp_rx_ports [1/2]

ap_uint<32> s_udp_rx_ports = 0x0

Definition at line 85 of file test_uppercase.cpp.

◆ s_udp_rx_ports [2/2]

ap_uint<32> s_udp_rx_ports = 0x0

Definition at line 82 of file test_uppercase.cpp.

◆ simCnt [1/2]

unsigned int simCnt

Definition at line 94 of file test_uppercase.cpp.

◆ simCnt [2/2]

unsigned int simCnt

Definition at line 91 of file test_uppercase.cpp.