title: How to flush hls::Mat?
body: <p>I need to stack the top half of two images(hls::Mat) together. I ended up having the following errors.</p>
  
  <blockquote>
    <p>WARNING: Hls::stream 'hls::stream.8' contains leftover   data, which may result in RTL simulation hanging.</p>
  </blockquote>
  
  <p>If I flush the leftover by </p>
  
  <pre><code>while (1){
      img_in0 &gt;&gt; p0;
      if (!p0.val[0])
          break;
  }
  </code></pre>
  
  <p>I got the following error</p>
  
  <blockquote>
    <p>WARNING: Hls::stream 'hls::stream.7' is read while empty, which may result in RTL simulation hanging.</p>
  </blockquote>
  
  <p>I wonder what is the best way to flush the leftover?</p>
  
  <pre><code>#define NO_PREFILTER
  
  #include "stereo_top.h"
  
  void combine2(
          GRAY_IMAGE&amp; img_in0,
          GRAY_IMAGE&amp; img_in1,
          GRAY_IMAGE&amp; img_out,
      int rows,
      int cols) {
  
  hls::Scalar&lt;1, unsigned char&gt; p0, p1, p;
  
  
  L_row: for(int row = 0; row &lt; rows; row++) {
  #pragma HLS LOOP_TRIPCOUNT min=1 max=1080
  
      L_col: for(int col = 0; col &lt; cols; col++) {
      #pragma HLS LOOP_TRIPCOUNT min=1 max=1920
      #pragma HLS pipeline rewind
          if(row&lt;(rows/2)) {
              img_in0 &gt;&gt; p0;
              p = p0;
          }
          else
          {
              img_in1 &gt;&gt; p1;
              p = p1;
          }
          img_out &lt;&lt; p;
      }
  
  }
  
  while (1){
      img_in0 &gt;&gt; p0;
      if (!p0.val[0])
          break;
  }
  
  }
  
  void stereo_filter_lr(AXI_STREAM&amp; imgLeft_axi, AXI_STREAM&amp; imgRight_axi, AXI_STREAM&amp; stereoOut, int rows, int cols)
  {
  #pragma HLS INTERFACE axis port=imgRight_axi
  #pragma HLS INTERFACE axis port=imgLeft_axi
  #pragma HLS INTERFACE ap_none port=cols
  #pragma HLS INTERFACE ap_none port=rows
  
  RGB_IMAGE   imgL_0(rows, cols);
  RGB_IMAGE   imgR_0(rows, cols);
  GRAY_IMAGE  img_L(rows, cols);
  GRAY_IMAGE  img_R(rows, cols);
  GRAY_IMAGE  disp(rows, cols);
  RGB_IMAGE           stereo(rows, cols);
  
  #pragma HLS dataflow
  
      //Recieve data stream and convert to Mat format
      hls::AXIvideo2Mat(imgLeft_axi, imgL_0);
      hls::AXIvideo2Mat(imgRight_axi, imgR_0);
  
      //Convert RGB Image to Gray Image
      hls::CvtColor&lt;HLS_BGR2GRAY&gt;(imgL_0, img_L);
      hls::CvtColor&lt;HLS_BGR2GRAY&gt;(imgR_0, img_R);
  
      combine2(img_L, img_R, disp, rows, cols);
  
      hls::CvtColor&lt;HLS_GRAY2BGR&gt;(disp, stereo);
      hls::Mat2AXIvideo(stereo, stereoOut);
      return;
  }
  </code></pre>