cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_warp_transform.cpp
Go to the documentation of this file.
1 
17 
36 #include "../include/warp_transform.hpp"
37 #include "../../common/src/common.cpp"
38 #include "../include/xf_warp_transform_config.h"
39 
40 using namespace std;
41 
42 //---------------------------------------------------------
43 // HELPERS FOR THE DEBUGGING TRACES
44 // .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)
45 //---------------------------------------------------------
46 #define THIS_NAME "TB"
47 
48 #define TRACE_OFF 0x0000
49 #define TRACE_URIF 1 << 1
50 #define TRACE_UAF 1 << 2
51 #define TRACE_MMIO 1 << 3
52 #define TRACE_ALL 0xFFFF
53 
54 #define DEBUG_LEVEL (TRACE_ALL)
55 
56 
57 //------------------------------------------------------
58 //-- TESTBENCH DEFINES
59 //------------------------------------------------------
60 #define OK true
61 #define KO false
62 #define VALID true
63 #define UNVALID false
64 #define DEBUG_TRACE true
65 
66 // The number of sequential testbench executions
67 #define TB_TRIALS 3
68 
69 // Enable delay in the response channel of DDR AXI controller
70 #define ENABLE_DDR_EMULATE_DELAY_IN_TB
71 
72 #define ENABLED (ap_uint<1>)1
73 #define DISABLED (ap_uint<1>)0
74 
75 
76 #if TRANSFORM_TYPE == 1
77 #define TRMAT_DIM2 3
78 #define TRMAT_DIM1 3
79 #else
80 #define TRMAT_DIM2 3
81 #define TRMAT_DIM1 2
82 #endif
83 
84 //------------------------------------------------------
85 //-- DUT INTERFACES AS GLOBAL VARIABLES
86 //------------------------------------------------------
87 
88 //-- SHELL / Uaf / Mmio / Config Interfaces
89 //ap_uint<2> piSHL_This_MmioEchoCtrl;
92 
93 //-- SHELL / Uaf / Udp Interfaces
94 stream<UdpWord> sSHL_Uaf_Data ("sSHL_Uaf_Data");
95 stream<UdpWord> sUAF_Shl_Data ("sUAF_Shl_Data");
96 stream<UdpWord> image_stream_from_warp_transform ("image_stream_from_warp_transform");
97 
98 ap_uint<32> s_udp_rx_ports = 0x0;
99 stream<NetworkMetaStream> siUdp_meta ("siUdp_meta");
100 stream<NetworkMetaStream> soUdp_meta ("soUdp_meta");
101 ap_uint<32> node_rank;
102 ap_uint<32> cluster_size;
103 
104 #ifdef ENABLE_DDR
105 
106 //------------------------------------------------------
107 //-- SHELL / Role / Mem / Mp0 Interface
108 //------------------------------------------------------
109 //---- Read Path (MM2S) ------------
110 stream<DmCmd> sROL_Shl_Mem_RdCmdP0("sROL_Shl_Mem_RdCmdP0");
111 stream<DmSts> sSHL_Rol_Mem_RdStsP0("sSHL_Rol_Mem_RdStsP0");
112 stream<Axis<MEMDW_512> > sSHL_Rol_Mem_ReadP0 ("sSHL_Rol_Mem_ReadP0");
113 //---- Write Path (S2MM) -----------
114 stream<DmCmd> sROL_Shl_Mem_WrCmdP0("sROL_Shl_Mem_WrCmdP0");
115 stream<DmSts> sSHL_Rol_Mem_WrStsP0("sSHL_Rol_Mem_WrStsP0");
116 stream<Axis<MEMDW_512> > sROL_Shl_Mem_WriteP0("sROL_Shl_Mem_WriteP0");
117 
118 //------------------------------------------------------
119 //-- SHELL / Role / Mem / Mp1 Interface
120 //------------------------------------------------------
121 #define MEMORY_LINES_512 TOTMEMDW_512 /* 64 KiB */
124 #endif
125 
126 //------------------------------------------------------
127 //-- TESTBENCH GLOBAL VARIABLES
128 //------------------------------------------------------
129 int simCnt;
130 
131 
132 
136 void stepDut() {
142  #ifdef ENABLE_DDR
143  ,
147  lcl_mem0,
148  lcl_mem1
149  #endif
150  );
151  simCnt++;
152  printf("[%4.4d] STEP DUT \n", simCnt);
153 }
154 
155 
156 
157 
158 
163 int main(int argc, char** argv) {
164 
165  //------------------------------------------------------
166  //-- TESTBENCH LOCAL VARIABLES
167  //------------------------------------------------------
168  int nrErr;
169  unsigned int tb_trials = 0;
170 
171  printf("#####################################################\n");
172  printf("## MAIN TESTBENCH STARTS HERE ##\n");
173  printf("#####################################################\n");
174 
175 
176  //------------------------------------------------------
177  //-- TESTBENCH LOCAL VARIABLES FOR WARPTRANSFORM
178  //------------------------------------------------------
179  cv::Mat in_img;
180  // float identity_tx_mat [9] = {1,0,0,0,1,0,0,0,0};
181  // float xtranslation_tx_mat [9] = {1,0,2,0,1,0,0,0,0};// 1 0 vx 0 1 vy 000
182  // float ytranslation_tx_mat [9] = {1,0,0,0,1,2,0,0,0};
183  // float reflection_tx_mat [9] = {-1,0,0,0,1,0,0,0,0};
184  // float yscale_tx_mat [9] = {2,0,0,0,1,0,0,0,0}; //cx 0 0 0 cy 0 000
185  // float xscale_tx_mat [9] = {1,0,0,0,2,0,0,0,0};
186  // float rotation_30degree_tx_mat [9] = {0.87,-0.5,0,0.5,0.87,0,0,0,0}; //cos -sin 0 sin cos 0 000
187  // float shearing_tx_mat [9] = {1,0.5,0,0,1,0,0,0,0}; //1 cx 0 cy 1 0 000
188  //float transformation_matrix_float [9] = {1,0,0,0,-1,256,0,0,0};// reflect wrt x
189  float transformation_matrix_float [9] = {1.5,0,0,0,1.8,0,0,0,0};
190  cv::Mat transformation_matrix(TRMAT_DIM1, TRMAT_DIM2, CV_32FC1, transformation_matrix_float);
191  cv::Mat hls_out_img, ocv_out_img;
192 
193  if (argc != 2) {
194  printf("Usage : %s <input image> \n", argv[0]);
195  return -1;
196  }
197  in_img = cv::imread(argv[1], 0); // reading in the color image
198 
199  if (!in_img.data) {
200  printf("ERROR: Failed to load the image ... %s\n!", argv[1]);
201  return -1;
202  }
203  else {
204  printf("INFO: Succesfully loaded image ... %s\n", argv[1]);
205  if (in_img.total() != FRAME_WIDTH * FRAME_HEIGHT) {
206  printf("WARNING: Resizing input image %s from [%u x %u] to [%u x %u] !\n", argv[1], in_img.rows, in_img.cols, FRAME_WIDTH, FRAME_HEIGHT);
207  cv::resize(in_img, in_img, cv::Size(FRAME_WIDTH, FRAME_HEIGHT), 0, 0, cv::INTER_LINEAR);
208  }
209  // Ensure that the selection of MTU is a multiple of 8 (Bytes per transaction)
210  assert(PACK_SIZE % 8 == 0);
211  }
212 
213  #ifdef ENABLE_DDR
214  memset(lcl_mem0, 0x0, sizeof(lcl_mem0));
215  memset(lcl_mem1, 0x0, sizeof(lcl_mem1));
216 
217  DmCmd dmCmd_MemCmdP0;
218  DmSts dmSts_MemWrStsP0;
219  DmSts dmSts_MemRdStsP0;
220  Axis<MEMDW_512> memP0;
221  ap_uint<64> currentMemPattern = 0;
222 
223  unsigned int ddr_addr_in = 0x0;
224  unsigned int ddr_write_req_iter = 0;
225  unsigned int wait_cycles_to_ack_ddr_status = 0;
226  unsigned int count_cycles_to_ack_ddr_status = 0;
227  bool ddr_write_sts_req = false;
228  #endif
229 
230 
231  //------------------------------------------------------
232  //-- STEP-1.1 : CREATE MEMORY FOR OUTPUT IMAGES
233  //------------------------------------------------------
234  // cvtColor(in_img, img_gray, CV_BGR2GRAY);
235  // Convert rgb into grayscale
236  hls_out_img.create(in_img.rows, in_img.cols, CV_8U); // create memory for hls output image
237  ocv_out_img.create(in_img.rows, in_img.cols, CV_8U); // create memory for opencv output image
238 
239  #if NO
240  static xf::cv::Mat<TYPE, HEIGHT, WIDTH, XF_NPPC1> imgInput(in_img.rows, in_img.cols);
241  static xf::cv::Mat<TYPE, HEIGHT, WIDTH, XF_NPPC1> imgOutput(in_img.rows, in_img.cols);
242  static xf::cv::Mat<TYPE, HEIGHT, WIDTH, XF_NPPC1> imgOutputTb(in_img.rows, in_img.cols);
243  imgInput.copyTo(in_img.data);
244  ap_uint<INPUT_PTR_WIDTH> *imgInputArray = (ap_uint<INPUT_PTR_WIDTH>*) malloc(in_img.rows * in_img.cols * sizeof(ap_uint<INPUT_PTR_WIDTH>));
245  ap_uint<OUTPUT_PTR_WIDTH> *imgOutputArrayTb = (ap_uint<OUTPUT_PTR_WIDTH>*) malloc(in_img.rows * in_img.cols * sizeof(ap_uint<OUTPUT_PTR_WIDTH>));
246  ap_uint<OUTPUT_PTR_WIDTH> *imgOutputArray = (ap_uint<OUTPUT_PTR_WIDTH>*) malloc(in_img.rows * in_img.cols * sizeof(ap_uint<OUTPUT_PTR_WIDTH>));
247  xf::cv::xfMat2Array<INPUT_PTR_WIDTH, TYPE, HEIGHT, WIDTH, NPIX>(imgInput, imgInputArray);
248  #endif
249 
250  #if RO
251  static xf::cv::Mat<TYPE, HEIGHT, WIDTH, XF_NPPC8> imgInput(in_img.rows, in_img.cols);
252  static xf::cv::Mat<TYPE, HEIGHT, WIDTH, XF_NPPC8> imgOutput(in_img.rows, in_img.cols);
253  static xf::cv::Mat<TYPE, HEIGHT, WIDTH, XF_NPPC1> imgOutputTb(in_img.rows, in_img.cols);
254  #endif
255 
256  // L2 Vitis WarpTransform
257  warptTransformAccelArray(imgInputArray, transformation_matrix_float,imgOutputArrayTb, in_img.rows, in_img.cols);
258  xf::cv::Array2xfMat<OUTPUT_PTR_WIDTH, TYPE, HEIGHT, WIDTH, NPIX>(imgOutputArrayTb, imgOutputTb);
259  if ( !dumpImgToFile ( imgOutputTb, "verify_UAF_Shl_Data.dat", simCnt) ) {
260  nrErr++;
261  }
262 
263  while (tb_trials++ < TB_TRIALS) {
264 
265 
266  printf ( "##################################################### \n" );
267  printf ( "## TESTBENCH #%u STARTS HERE ##\n", tb_trials );
268  printf ( "##################################################### \n" );
269 
270 
271  simCnt = 0;
272  nrErr = 0;
273 
274 #if NO
275  if ( !dumpImgToFileWarpTransform ( imgInput, "ifsSHL_Uaf_Data.dat", simCnt, transformation_matrix_float ) ) {
276  nrErr++;
277  }
278 #endif
279 
280 #if RO
281  // imgInput.copyTo(img_gray.data);
282  imgInput = xf::cv::imread<TYPE, HEIGHT, WIDTH, XF_NPPC8> ( argv[1], 0 );
283 #endif
284 
285 
286 
287  //------------------------------------------------------
288  //-- STEP-1.2 : RUN WARPTRANSFORM DETECTOR FROM OpenCV LIBRARY
289  //------------------------------------------------------
290  // ksize: aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ...
291  //int ksize = WINDOW_SIZE ;
292  ocv_ref ( in_img, ocv_out_img, transformation_matrix);
293 
294 
295 
296  //------------------------------------------------------
297  //-- STEP-2.1 : CREATE TRAFFIC AS INPUT STREAMS
298  //------------------------------------------------------
299  if ( nrErr == 0 ) {
300  if ( !setInputDataStream ( sSHL_Uaf_Data, "sSHL_Uaf_Data", "ifsSHL_Uaf_Data.dat", simCnt ) ) {
301  printf ( "### ERROR : Failed to set input data stream \"sSHL_Uaf_Data\". \n" );
302  nrErr++;
303  }
304 
305  //there are TOT_TRANSFERS streams from the the App to the Role
307  std::cout << "DEBUG: tx transfer=" << TOT_TRANSFERS_TX << " rx=" << TOT_TRANSFERS_RX << std::endl;
308  for ( int i=0; i<TOT_TRANSFERS_TX; i++ ) {
309  siUdp_meta.write ( NetworkMetaStream ( tmp_meta ) );
310  }
311  //set correct node_rank and cluster_size
312  node_rank = 1;
313  cluster_size = 2;
314  }
315 
316  //------------------------------------------------------
317  //-- STEP-2.2 : SET THE PASS-THROUGH MODE
318  //------------------------------------------------------
319  //piSHL_This_MmioEchoCtrl.write(ECHO_PATH_THRU);
320  //[TODO] piSHL_This_MmioPostPktEn.write(DISABLED);
321  //[TODO] piSHL_This_MmioCaptPktEn.write(DISABLED);
322 
323  //------------------------------------------------------
324  //-- STEP-3 : MAIN TRAFFIC LOOP
325  //------------------------------------------------------
326  while ( !nrErr ) {
327 
328  // Keep enough simulation time for sequntially executing the FSMs of the main 3 functions
329  // (Rx-Proc-Tx)
330  if ( simCnt < MIN_RX_LOOPS + MIN_RX_LOOPS + MIN_TX_LOOPS + 10 + 2 + 4
331 #ifdef ENABLE_DDR
334 #endif
335 #endif
336  ) {
337  stepDut();
338 
339  if ( simCnt > 2 ) {
340  assert ( s_udp_rx_ports == PORTS_OPENED );
341  }
342 
343 if (simCnt < 0)
344  exit(0);
345 #ifdef ENABLE_DDR
346 
347  if ( !sROL_Shl_Mem_WrCmdP0.empty() ) {
348  printf ( "DEBUG tb: Read a memory write command from SHELL/Mem/Mp0 \n" );
349  //-- Read a memory write command from SHELL/Mem/Mp0
350  sROL_Shl_Mem_WrCmdP0.read ( dmCmd_MemCmdP0 );
351  //assert ( dmCmd_MemCmdP0.bbt == CHECK_CHUNK_SIZE );
352  assert ( dmCmd_MemCmdP0.type == 1 && dmCmd_MemCmdP0.dsa == 0 && dmCmd_MemCmdP0.eof == 1 && dmCmd_MemCmdP0.drr == 1 && dmCmd_MemCmdP0.tag == 0x0 );
353  ddr_addr_in = (unsigned int)dmCmd_MemCmdP0.saddr / BPERMDW_512; // Convert the byte-aligned address to local mem of stack tb.
354  printf ( "DEBUG tb: Requesting writting to address %u (max depth = %u) an amount of %u bytes (%u memory lines), ddr_write_req_iter=%u\n", ddr_addr_in, MEMORY_LINES_512-1, (unsigned int)dmCmd_MemCmdP0.bbt, (unsigned int)(1 + (dmCmd_MemCmdP0.bbt - 1) / BPERMDW_512), ddr_write_req_iter);
355  assert (ddr_addr_in <= MEMORY_LINES_512-1);
356  //ddr_write_req_iter++;
357  //printf ( "DEBUG tb: (ddr_write_req_iter)%(MEMORY_LINES_512-1)=%u\n", (ddr_write_req_iter)%(MEMORY_LINES_512-1));
358  if ((++ddr_write_req_iter)%(MEMORY_LINES_512) == 0) {
359  ddr_write_req_iter = 0;
360  }
361  printf ( "DEBUG tb: ddr_write_req_iter=%u\n", ddr_write_req_iter);
362 
363 #ifdef ENABLE_DDR_EMULATE_DELAY_IN_TB
364  /*
365  * 16 -> emulate a response in 16 cycles
366  * 1 -> emulate immediate response
367  * CYCLES_UNTIL_TIMEOUT -> on purpose timeout
368  */
369  if (ddr_write_req_iter == 1) {
370  wait_cycles_to_ack_ddr_status = TYPICAL_DDR_LATENCY;
371  }
372  else if (ddr_write_req_iter == 2) {
373  wait_cycles_to_ack_ddr_status = TYPICAL_DDR_LATENCY;
374  }
375  else {
376  wait_cycles_to_ack_ddr_status = TYPICAL_DDR_LATENCY;
377  }
378  if (!sSHL_Rol_Mem_WrStsP0.empty()) {
379  printf("WARNING: Emptying sSHL_Rol_Mem_WrStsP0 fifo.\n");
380  dmSts_MemWrStsP0 = sSHL_Rol_Mem_WrStsP0.read();
381  }
382 #else
383  wait_cycles_to_ack_ddr_status = 0;
384 #endif
385  count_cycles_to_ack_ddr_status = 0;
386  ddr_write_sts_req = false;
387  }
388 
389  if ( !sROL_Shl_Mem_WriteP0.empty() ) {
390  sROL_Shl_Mem_WriteP0.read ( memP0 );
391  printf ( "DEBUG tb: Write a memory line from SHELL/Mem/Mp0 \n" );
392 
393  assert ( memP0.tkeep == 0xffffffffffffffff );
394 
395  /* Read from AXI stream DDR interface and write to the memory mapped interface of
396  * DDR channel P0. In the real HW, this is enabled by the AXI interconnect and AXI
397  * Datamover, being instantiated in VHDL.
398  * */
399  // printf ( "DEBUG tb: Writting to address 0x%x : %u an amount of %u bytes\n", ddr_addr_in, memP0.tdata.to_long(), BPERMDW_512);
400  std::cout << "DEBUG tb: Writting to address 0x" << std::hex << ddr_addr_in << " : " << memP0.tdata << " an amount of " << std::dec << BPERMDW_512 << " bytes" << std::endl;
401  //lcl_mem0[ddr_addr_in++] = memP0.tdata;
402  memcpy(&lcl_mem0[ddr_addr_in++], &memP0.tdata, BPERMDW_512);
403  ddr_write_sts_req = true;
404  }
405  // When we have emulated the writting to lcl_mem0, we acknowledge with a P0 status
406  if ((ddr_write_sts_req == true) && !sSHL_Rol_Mem_WrStsP0.full() && (memP0.tlast == true)) {
407  if (count_cycles_to_ack_ddr_status++ == wait_cycles_to_ack_ddr_status) {
408  dmSts_MemWrStsP0.tag = 0;
409  dmSts_MemWrStsP0.okay = 1;
410  dmSts_MemWrStsP0.interr = 0;
411  dmSts_MemWrStsP0.slverr = 0;
412  dmSts_MemWrStsP0.decerr = 0;
413  printf ( "DEBUG tb: Write a memory status command to SHELL/Mem/Mp0 \n" );
414  sSHL_Rol_Mem_WrStsP0.write ( dmSts_MemWrStsP0 );
415  ddr_write_sts_req = false;
416  }
417  else{
418  printf ( "DEBUG tb: Waiting to write a memory status command to SHELL/Mem/Mp0 [%u out of %u] cycles\n", count_cycles_to_ack_ddr_status, wait_cycles_to_ack_ddr_status);
419  }
420  }
421 
422 
423 
424 #endif // ENABLE_DDR
425 
426 
427  //if( !soUdp_meta.empty())
428  //{
429  // NetworkMetaStream tmp_meta = soUdp_meta.read();
430  // printf("NRC received NRCmeta stream from node_rank %d.\n", (int) tmp_meta.tdata.src_rank);
431  //}
432 
433 
434  } else {
435 #ifdef ENABLE_DDR
436  if (!sSHL_Rol_Mem_WrStsP0.empty()) {
437  printf("WARNING: Emptying sSHL_Rol_Mem_WrStsP0 fifo.\n");
438  dmSts_MemWrStsP0 = sSHL_Rol_Mem_WrStsP0.read();
439  }
440 #endif
441  printf ( "## End of simulation at cycle=%3d. \n", simCnt );
442  break;
443  }
444 
445  } // End: while()
446 
447  //-------------------------------------------------------
448  //-- STEP-4 : DRAIN AND WRITE OUTPUT FILE STREAMS
449  //-------------------------------------------------------
450  //---- UAF-->SHELL Data ----
451  if ( !getOutputDataStream ( sUAF_Shl_Data, "sUAF_Shl_Data", "ofsUAF_Shl_Data.dat", simCnt ) ) {
452  nrErr++;
453  }
454  //---- UAF-->SHELL META ----
455  if ( !soUdp_meta.empty() ) {
456  int i = 0;
457  while ( !soUdp_meta.empty() ) {
458  i++;
459  NetworkMetaStream tmp_meta = soUdp_meta.read();
460  printf ( "NRC received NRCmeta stream from rank %d to rank %d.\n", ( int ) tmp_meta.tdata.src_rank, ( int ) tmp_meta.tdata.dst_rank );
461  assert ( tmp_meta.tdata.src_rank == node_rank );
462  //ensure forwarding behavior
463  assert ( tmp_meta.tdata.dst_rank == ( ( tmp_meta.tdata.src_rank + 1 ) % cluster_size ) );
464  }
465  //printf("DEBUG: i=%u\tTOT_TRANSFERS=%u\n", i, TOT_TRANSFERS);
466  assert ( i == TOT_TRANSFERS_RX );
467  } else {
468  printf ( "Error No metadata received...\n" );
469  nrErr++;
470  }
471 
472  //-------------------------------------------------------
473  //-- STEP-5 : FROM THE OUTPUT FILE CREATE AN ARRAY
474  //-------------------------------------------------------
475  if ( !setInputFileToArray ( "ofsUAF_Shl_Data.dat", imgOutputArray, simCnt ) ) {
476  printf ( "### ERROR : Failed to set input array from file \"ofsUAF_Shl_Data.dat\". \n" );
477  nrErr++;
478  }
479  xf::cv::Array2xfMat<OUTPUT_PTR_WIDTH, TYPE, HEIGHT, WIDTH, NPIX> ( imgOutputArray, imgOutput );
480 
481 
482  //------------------------------------------------------
483  //-- STEP-6 : COMPARE INPUT AND OUTPUT FILE STREAMS
484  //------------------------------------------------------
485  int rc1 = system ( "diff --brief -w -i -y ../../../../test/ofsUAF_Shl_Data.dat \
486  ../../../../test/verify_UAF_Shl_Data.dat" );
487  if ( rc1 ) {
488  printf ( "## Error : File \'ofsUAF_Shl_Data.dat\' does not match \'verify_UAF_Shl_Data.dat\'.\n" );
489  } else {
490  printf ( "Output data in file \'ofsUAF_Shl_Data.dat\' verified.\n" );
491  }
492  const string outfilename = "hls_out-"+std::to_string(tb_trials)+".jpg";
493  xf::cv::imwrite(outfilename.c_str(), imgOutput);
494 
495  nrErr += rc1;
496 
497  printf ( "#####################################################\n" );
498  if ( nrErr ) {
499  printf ( "## ERROR - TESTBENCH #%u FAILED (RC=%d) !!! ##\n", tb_trials, nrErr );
500  } else {
501  printf ( "## SUCCESSFULL END OF TESTBENCH #%u (RC=0) ##\n", tb_trials );
502  }
503  printf ( "#####################################################\n" );
504 
505 
506 
507 
508 
509  } // End tb trials while loop
510 
511 
512 
513 
514 
515 
516 
517 
519  // #if NO
520 
521  // // L2 Vitis WarpTransform
522  // warptTransformAccelArray(imgInputArray, transformation_matrix_float,imgOutputArrayTb, in_img.rows, in_img.cols);
523  // xf::cv::Array2xfMat<OUTPUT_PTR_WIDTH, TYPE, HEIGHT, WIDTH, NPIX>(imgOutputArrayTb, imgOutputTb);
524 
525  // // L1 Vitis WarpTransform
526  // //warp_transform_accel(imgInput, imgOutput, Thresh, k);
527 
528  // #endif
529 
530  // #if RO
531 
532  // warp_transform_accel(imgInput, imgOutputTb);
533 
534  // #endif
535 
537  xf::cv::imwrite("hls_out_tb.jpg", imgOutputTb);
538  xf::cv::imwrite("hls_out.jpg", imgOutput);
539  cv::imwrite("ocv_ref_out.jpg", ocv_out_img);
540 
541  unsigned int val;
542  unsigned short int row, col;
543 
544  cv::Mat out_img;
545  out_img = in_img.clone();
546 
547  std::vector<cv::Point> hls_points;
548  std::vector<cv::Point> ocv_points;
549  std::vector<cv::Point> common_pts;
550 
551  xf::cv::Mat<TYPE, HEIGHT, WIDTH, NPIX>* select_imgOutput;
552 
553  // Select which output you want to process for image outputs and corners comparisons:
554  // &imgOutput : The processed image by WarpTransform IP inside the ROLE (i.e. I/O traffic is passing through SHELL)
555  // &imgOutputTb : The processed image by WarpTransform IP in this testbench (i.e. I/O traffic is done in testbench)
556  select_imgOutput = &imgOutput;
557 
558  // Clear memory
559  free(imgOutputArrayTb);
560  free(imgOutputArray);
561  free(imgInputArray);
562 
563 
564  return(nrErr);
565 }
566 
567 
568 
569 
ap_uint< 64 > currentMemPattern
ap_uint< 40 > saddr
ap_uint< 1 > drr
ap_uint< 1 > eof
ap_uint< 23 > bbt
ap_uint< 4 > tag
ap_uint< 6 > dsa
ap_uint< 1 > type
ap_uint< 1 > okay
ap_uint< 1 > decerr
ap_uint< 1 > slverr
ap_uint< 4 > tag
ap_uint< 1 > interr
void ocv_ref(cv::Mat img_gray, cv::Mat &ocv_out_img, float Th)
Definition: xf_ocv_ref.hpp:552
#define FRAME_HEIGHT
Definition: config.h:43
#define FRAME_WIDTH
Definition: config.h:46
#define BPERMDW_512
Definition: harris.hpp:120
#define PORTS_OPENED
Definition: harris.hpp:102
#define MIN_TX_LOOPS
#define MIN_RX_LOOPS
#define EXTRA_DDR_LATENCY_DUE_II
Definition: memtest.hpp:99
#define DDR_LATENCY
Definition: memtest.hpp:98
#define ENABLE_DDR
Definition: memtest.hpp:42
membus_512_t membus_t
Definition: memtest.hpp:92
#define TYPICAL_DDR_LATENCY
Definition: memtest.hpp:97
#define PACK_SIZE
Definition: config.h:51
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
bool dumpImgToFileWarpTransform(xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &_img, const string outFileName, int simCnt, float *transform_matrix)
Fill an output file with data from an image.
Definition: common.cpp:304
bool dumpImgToFile(xf::cv::Mat< OUT_TYPE, HEIGHT, WIDTH, NPIX > &_img, const std::string outFileName, int simCnt)
Fill an output file with data from an image.
bool setInputFileToArray(const std::string inpFileName, ap_uint< OUTPUT_PTR_WIDTH > *imgArray, int simCnt)
Initialize an input array from a file with format "tdata tkeep tlast".
void warp_transform(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, stream< DmCmd > &soMemWrCmdP0, stream< DmSts > &siMemWrStsP0, stream< Axis< 512 > > &soMemWriteP0, membus_t *lcl_mem0, membus_t *lcl_mem1)
stream< DmSts > sSHL_Rol_Mem_RdStsP0("sSHL_Rol_Mem_RdStsP0")
stream< UdpWord > image_stream_from_warp_transform("image_stream_from_warp_transform")
#define TRMAT_DIM2
#define TB_TRIALS
membus_t lcl_mem0[(1+(32 *32 - 1)/(512/8))]
stream< NetworkMetaStream > siUdp_meta("siUdp_meta")
stream< Axis< 512 > > sSHL_Rol_Mem_ReadP0("sSHL_Rol_Mem_ReadP0")
int main(int argc, char **argv)
Main testbench of Hrris.
stream< NetworkMetaStream > soUdp_meta("soUdp_meta")
#define TRMAT_DIM1
int simCnt
stream< Axis< 512 > > sROL_Shl_Mem_WriteP0("sROL_Shl_Mem_WriteP0")
ap_uint< 1 > piSHL_This_MmioCaptPktEn
ap_uint< 1 > piSHL_This_MmioPostPktEn
stream< DmCmd > sROL_Shl_Mem_WrCmdP0("sROL_Shl_Mem_WrCmdP0")
stream< UdpWord > sUAF_Shl_Data("sUAF_Shl_Data")
membus_t lcl_mem1[(1+(32 *32 - 1)/(512/8))]
stream< DmCmd > sROL_Shl_Mem_RdCmdP0("sROL_Shl_Mem_RdCmdP0")
void stepDut()
Run a single iteration of the DUT model.
#define MEMORY_LINES_512
stream< UdpWord > sSHL_Uaf_Data("sSHL_Uaf_Data")
stream< DmSts > sSHL_Rol_Mem_WrStsP0("sSHL_Rol_Mem_WrStsP0")
#define ENABLE_DDR_EMULATE_DELAY_IN_TB
ap_uint< 32 > cluster_size
ap_uint< 32 > s_udp_rx_ports
ap_uint< 32 > node_rank
void warptTransformAccelArray(ap_uint< 8 > *img_in, float *transform, ap_uint< 64 > *img_out, int rows, int cols)
Top-level accelerated function of the WarptTransform Application with array I/F used only for simulat...
ap_uint<(D+7)/8 > tkeep
Definition: axi_utils.hpp:49
ap_uint< 1 > tlast
Definition: axi_utils.hpp:50
ap_uint< D > tdata
Definition: axi_utils.hpp:48
NetworkMeta tdata
Definition: network.hpp:109
NodeId dst_rank
Definition: network.hpp:95
NodeId src_rank
Definition: network.hpp:97