Hi All,
I am using PYNQ Z2 v2.6 for accelerating an image processing algorithm. I noticed that my output buffer is filling with 0 or maybe my ip is not writing in these positions as specific. To be more specific, 4 indexes after every 4 elements (0,1,2,3 will be filled with the required value then 4,5,6,7 will be filled with 0 and then 8,9,10,11 with the required value and then again 12,13,14,15 with 0 and so on).
I suspected this might be because of my image processing logic happening. Therefore, I rewrote my custom ip logic as just taking input image and returning the same image as output without any processing of the image.
Still now I am seeing the same behaviour. I have hereby attached the output as well as the code below. The simulation works as required always but when moved into the PYNQ board it is not working as required. What could be the possible reason?
Can someone please help me? I am working on a time constraint project.
Custom Ip
void img_processing(ap_uint<8>* inp_stream, ap_uint<8>* output_stream, unsigned int rows, unsigned int cols){
#pragma HLS INTERFACE m_axi port=inp_stream offset=slave bundle=gem1
#pragma HLS INTERFACE m_axi port=output_stream offset=slave bundle=gem2
#pragma HLS INTERFACE s_axilite port=rows offset=0x10
#pragma HLS INTERFACE s_axilite port=cols offset=0x18
#pragma HLS INTERFACE s_axilite port=return
//defining all the required Mat
xf::cv::Mat<XF_8UC1, MAX_HEIGHT, MAX_WIDTH, XF_NPPC1> in_mat(rows,cols);
#pragma HLS DATAFLOW
for (int i=0; i< (rows * cols); i++){
in_mat.write(i, inp_stream[i]);
}
for (int i=0; i< (rows * cols); i++){
output_stream[i] = in_mat.read(i);
}
}
Python Code
from PIL import Image
from pynq import Overlay, allocate
import numpy as np
overlay = Overlay('edge_detection.bit')
regs = overlay.sobel_filter_0.register_map
sobel = overlay.sobel_filter_0
im = Image.open('./sobel.png')
im_gray = im.convert('L')
display(im_gray)
random_data = np.random.randint(0, 256, size=(10, 10), dtype=np.uint8)
buf_in = allocate(
(10,10), np.uint8, cacheable=True )
buf_in[:] = random_data
buf_out = allocate(
(10,10), np.uint8, cacheable=True )
regs.inp_stream_1 = buf_in.device_address
regs.output_stream_1 = buf_out.device_address
regs.rows = 10
regs.cols = 10
sobel.write(0x00,0x01)
regs
print(buf_in)
print(buf_out)
Hoping for a response soon !
Regards & Thanks in Advance,
Srijith