# Output getting filled with zero

**URL:** <https://discuss.pynq.io/t/output-getting-filled-with-zero/6697>\
**Category:** Support\
**Created:** [March 1, 2024, 12:44pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697 "2024-03-01T12:44:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![srijith.krishnan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/srijith.krishnan/32/5515_2.png) [@srijith.krishnan](https://discuss.pynq.io/u/srijith.krishnan)\
**Post date:** [March 1, 2024, 12:44pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/1 "2024-03-01T12:44:45Z")

</div>

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**

```auto
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**

```auto
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)

```

 ![py_output](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/e/e697717d218e67e0cce35302814a47b2076c2f4d.png)

Hoping for a response soon !

Regards & Thanks in Advance,  
Srijith

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [March 1, 2024, 8:53pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/2 "2024-03-01T20:53:56Z")

</div>

Hi @srijith.krishnan,

How is the IP connected? What is the bit width of the HP port where the IP is connected?

Mario

---

<div class="post-metadata">

**Author:** ![srijith.krishnan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/srijith.krishnan/32/5515_2.png) [@srijith.krishnan](https://discuss.pynq.io/u/srijith.krishnan)\
**Post date:** [March 4, 2024, 8:47am UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/3 "2024-03-04T08:47:43Z")

</div>

Hi @marioruiz,

Thank you for the response !

The data width for HP port is 64 width and the addr width is 32. Just to confirm, the 64 here is bytes right?

IP Connection:

 ![ip_connection](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/7/74409508e1b5ca33428efbe9d374f5490a996381.png)

Data Width HP Port:

 ![hpowidth](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/8/86421365495dff89478fdcc0a33d41b2b1323c97.png)

Regards,  
Srijith

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [March 4, 2024, 10:31am UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/4 "2024-03-04T10:31:22Z")

</div>

Hi, this is bits. You should change the data width of the HP port to 32-bit.

---

<div class="post-metadata">

**Author:** ![srijith.krishnan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/srijith.krishnan/32/5515_2.png) [@srijith.krishnan](https://discuss.pynq.io/u/srijith.krishnan)\
**Post date:** [March 4, 2024, 1:51pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/5 "2024-03-04T13:51:28Z")

</div>

Hi @marioruiz ,

I tried changing the HP port to 32 bit but still I am seeing the same behaviour.

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [March 4, 2024, 2:40pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/6 "2024-03-04T14:40:49Z")

</div>

What is the bitwidth of gem ports in the IP?

---

<div class="post-metadata">

**Author:** ![srijith.krishnan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/srijith.krishnan/32/5515_2.png) [@srijith.krishnan](https://discuss.pynq.io/u/srijith.krishnan)\
**Post date:** [March 4, 2024, 2:53pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/7 "2024-03-04T14:53:41Z")

</div>

@marioruiz, it was initially set to 64 bit but I changed them both to 32 bit. But still it is showing the same behaviour. The difference I see is that the protocol used for the gem ports are AXI3 and the protocol for HP port is AXI4.

 ![gem](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/3/3433b5713eb4c09485cce4484ddc68621d9c7d54.png)

---

<div class="post-metadata">

**Author:** ![srijith.krishnan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/srijith.krishnan/32/5515_2.png) [@srijith.krishnan](https://discuss.pynq.io/u/srijith.krishnan)\
**Post date:** [March 4, 2024, 3:13pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/8 "2024-03-04T15:13:09Z")

</div>

Also @marioruiz , what is the difference between ‘ID Ports’ and ‘USER Ports’ here?

 ![ip_definition](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/2X/6/65e4bb9392fffedaff3ac438b1c6490c36ba17d9.png)

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [March 4, 2024, 5:10pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/9 "2024-03-04T17:10:38Z")

</div>

Where are you changing these values? This should be done in the Zynq 7000 IP

---

<div class="post-metadata">

**Author:** ![srijith.krishnan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/srijith.krishnan/32/5515_2.png) [@srijith.krishnan](https://discuss.pynq.io/u/srijith.krishnan)\
**Post date:** [March 4, 2024, 5:20pm UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/10 "2024-03-04T17:20:01Z")

</div>

@marioruiz , The HP port width I changed them within the ZYNQ 7000 IP but the gem one I changed by double clicking the custom IP.

Can those also be changed within the ZYNQ ip? If so, Can you please guide me through?

---

<div class="post-metadata">

**Author:** ![Reatelf](https://avatars.discourse-cdn.com/v4/letter/r/71c47a/32.png) [@Reatelf](https://discuss.pynq.io/u/Reatelf)\
**Post date:** [April 3, 2024, 7:20am UTC](https://discuss.pynq.io/t/output-getting-filled-with-zero/6697/11 "2024-04-03T07:20:03Z")

</div>

Thank you!! sharing for this…  
[www.mybalancenow.com visa](https://mybalancenow.fun/)
