cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jiajiahao069
Visitor
Visitor
276 Views
Registered: ‎10-02-2020

how to avoid the pipeling hang

Hello, I am using the vivado_hls 2019.2 to develop the isp pipeline. The whole pipeline just like the following.

mipi input ->demosic ip-> hls ip ->frame buffer write.

mipi input ->demosic ip-> frame buffer write pipeline works normally. But when I insert hls ip. the pipeline hang. I add the ila to check and find the hls ip ready signal is low.

I check the hls ip latency and function match the requriment. The following code will make the pipeline hang.

void mat_combin_rgb_ccm( float r_gain1, float g_gain1, float b_gain1,
float r_gain2, float g_gain2, float b_gain2,
float r_gain3, float g_gain3, float b_gain3,
xf::cv::Mat<XF_8UC1,HEIGHT,WIDTH,PNPPC> &_r,
xf::cv::Mat<XF_8UC1,HEIGHT,WIDTH,PNPPC> &_g,
xf::cv::Mat<XF_8UC1,HEIGHT,WIDTH,PNPPC> &_b,
xf::cv::Mat<XF_8UC3,HEIGHT,WIDTH,PNPPC> &_dest)
{
#pragma HLS DATAFLOW

ap_uint<24 * PNPPC> dout;
ap_uint<8 * PNPPC> r, g, b;
float rf,gf,bf;
float r_result,g_result,b_result;
float r_result1,g_result1,b_result1;
//rg = r_gain; gg = g_gain; bg = b_gain;
#pragma HLS INLINE
for(int x=0; x< HEIGHT; x++){

for(int y = 0; y<(WIDTH >> XF_BITSHIFT(PNPPC)); y++){
#pragma HLS PIPELINE
b = _b.read(x * (WIDTH >> XF_BITSHIFT(PNPPC)) +y);
g = _g.read(x * (WIDTH >> XF_BITSHIFT(PNPPC)) +y);
r = _r.read(x * (WIDTH >> XF_BITSHIFT(PNPPC)) +y);

for(int i = 0; i< (1 << XF_BITSHIFT(PNPPC));i++){
#pragma HLS UNROLL
bf = (float) b(i * 8 + 7, i * 8);
gf = (float) g(i * 8 + 7, i * 8);
rf = (float) r(i * 8 + 7, i * 8);
//printf("<Executable Name> <input image path> y=%0d \n",y);
r_result1 = rf*r_gain1 + gf*g_gain1+ bf*b_gain1;
g_result1 = rf*r_gain2 + gf*g_gain2+ bf*b_gain2;
b_result1 = rf*r_gain3 + gf*g_gain3+ bf*b_gain3;

if (r_result1 >= 255)
r_result1 =255;
else if (r_result1 <=0)
r_result1 = 0;

if (g_result1 >= 255)
g_result1 =255;
else if(g_result1 <=0)
g_result1 =0;

if (b_result1 >= 255)
b_result1 =255;
else if (b_result1 <= 0)
b_result1 =0;

dout(23 + i*24, i * 24)=
(ap_uint<8>(b_result1),ap_uint<8>(g_result1),ap_uint<8>(r_result1));

}
_dest.write((x * (WIDTH >> XF_BITSHIFT(PNPPC)) + y), dout);
}
}
}

 

I must change the code like this. the pipeline can work normally. do you know what the reason make the pipeline hang? how to modify the code to avoid the pipeline hang?

void mat_combin_rgb_ccm( float r_gain1, float g_gain1, float b_gain1,
                         float r_gain2, float g_gain2, float b_gain2,
                         float r_gain3, float g_gain3, float b_gain3,
                         xf::cv::Mat<XF_8UC1,HEIGHT,WIDTH,PNPPC> &_r,
                         xf::cv::Mat<XF_8UC1,HEIGHT,WIDTH,PNPPC> &_g,
                         xf::cv::Mat<XF_8UC1,HEIGHT,WIDTH,PNPPC> &_b,
                         xf::cv::Mat<XF_8UC3,HEIGHT,WIDTH,PNPPC> &_dest)
{
#pragma HLS DATAFLOW

    ap_uint<24 * PNPPC> dout;
    ap_uint<8 * PNPPC> r, g, b;
    float rf,gf,bf;
    float r_result,g_result,b_result;
    float r_result1,g_result1,b_result1;
    //rg = r_gain; gg = g_gain; bg = b_gain;
#pragma HLS INLINE
    for(int x=0; x< HEIGHT; x++){
        
        for(int y = 0; y<(WIDTH >> XF_BITSHIFT(PNPPC)); y++){
#pragma HLS PIPELINE
            b = _b.read(x * (WIDTH >> XF_BITSHIFT(PNPPC)) +y);
            g = _g.read(x * (WIDTH >> XF_BITSHIFT(PNPPC)) +y);
            r = _r.read(x * (WIDTH >> XF_BITSHIFT(PNPPC)) +y);
            
            for(int i = 0; i< (1 << XF_BITSHIFT(PNPPC));i++){
#pragma HLS UNROLL
                bf = (float) b(i * 8 + 7, i * 8);
                gf = (float) g(i * 8 + 7, i * 8);
                rf = (float) r(i * 8 + 7, i * 8);
                //printf("<Executable Name> <input image path> y=%0d \n",y);
                r_result = rf*r_gain1    +gf*g_gain1;
                g_result = gf*g_gain2    +bf*b_gain2;
                b_result = rf*r_gain3    +bf*b_gain3;

                r_result1 = r_result + bf*b_gain1;
                g_result1 = g_result + rf*r_gain2;
                b_result1 = b_result + gf*g_gain3;

                if (r_result1 >= 255)
                	r_result1 =255;
                else if (r_result1 <=0)
                    r_result1 = 0;
               
                if (g_result1 >= 255)
                    g_result1 =255;
                else if(g_result1 <=0)
                    g_result1 =0;

                if (b_result1 >= 255)
                    b_result1 =255;
                else if (b_result1 <= 0)
                    b_result1 =0;

                dout(23 + i*24, i * 24)=
                    (ap_uint<8>(b_result1),ap_uint<8>(g_result1),ap_uint<8>(r_result1));

            }
            _dest.write((x * (WIDTH >> XF_BITSHIFT(PNPPC)) + y), dout);
        }    
    }    
}

 

0 Kudos
1 Reply
dsakjl
Voyager
Voyager
204 Views
Registered: ‎07-20-2018

Hi @jiajiahao069 ,

I suggest you to try using the enabe_flush option in HLS pipeline pragma.

Best regards.

0 Kudos