How to tell to write(offset,value) also the amount of bytes

Hello, I’ve done a 2D convolution IP in vivado HLS, and with the SDK everything worked well. (I put the array of 640x360 pixels there and save it in the memory).

My thing is, that after this I tried doing it using PYNQ library with a jupyter notebook. The kernel that I am multipliyng to my image is a 3x3 and in the vivadoHLS I see these addresses:

When I call the function of write(offset,value) the addresses must be mulptiple of 4, register of 4 bytes, but I wanna send just 9 bytes, How can I do this?



The conv object will have an .mmio object which performs the memory-mapped IO and core to that is the .array object which is a numpy array to do what you want. So first you could get an array of unsigned bytes and select the nine bytes you want

 filter = conv.mmio.array.view('u1')[0x10:0x19] # 'i1' if signed
 filter[:] = range(0,9)

You can also use the reshape function on the array to get a 2-dimensional view of memory

filter2d = filter.reshape((3,3))
filter2d[:]  = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]

Note that on Zynq Ultrascale devices you might run into issues with unaligned memory accesses if you’re not careful - the underlying numpy copying routines don’t make sure to align reads and writes. This is one of the reasons we only support 4 byte writes in our default implementation.

Peter

1 Like

thanks!