# Read entire array

**URL:** <https://discuss.pynq.io/t/read-entire-array/2488>\
**Category:** Support\
**Created:** [March 29, 2021, 4:14pm UTC](https://discuss.pynq.io/t/read-entire-array/2488 "2021-03-29T16:14:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickcamel](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/nickcamel/32/1650_2.png) [@nickcamel](https://discuss.pynq.io/u/nickcamel)\
**Post date:** [March 29, 2021, 4:14pm UTC](https://discuss.pynq.io/t/read-entire-array/2488/1 "2021-03-29T16:14:19Z")

</div>

I have an IP/overlay which saves data to an array: `ap_uint<14> usr_gpio[32]`.  
Now, once the IP has finished its run, I go ahead and read the values from PS.

Loading the overlay

```
overlay = Overlay('./my_ip.bit')
self.my_ol = overlay.my_overlay

```

And I know the array starts at `0x40` and I also know that each read  
`self.my_ol.read(0x40)`  
returns 2 elements of the array, i.e. 14 bits and 4 adresses. So in order for me to read entire array I have to loop 16 times through

```
for k in range(0, 64, 4):
    value = self.my_ol.read(0x40 + k)

```

Whatever…

My question is, is there a way to read the entire array in one go? E.g. adding `length` to the `read` function. I’ve seen some topics/examples using MMIO which I couldn’t really fit in to my issue.

---

<div class="post-metadata">

**Author:** ![PeterOgden](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/peterogden/32/55_2.png) [@PeterOgden](https://discuss.pynq.io/u/PeterOgden)\
**Post date:** [March 29, 2021, 4:29pm UTC](https://discuss.pynq.io/t/read-entire-array/2488/2 "2021-03-29T16:29:52Z")

</div>

Each device driver has a `.mmio` property which gives you direct access to the MMIO instance which you could then use with the other examples. In your case the point of interest is probably using `my_ol.mmio.array` which will be a numpy array of the memory mapped region.

Note that you use array indices rather than addresses to access the memory - so `my_ol.mmio.array[0x10:0x20]`

On Zynq Ultrascale+ you have to be very careful with memory alignment when accessing memory in this way. Zynq-7000 is slightly more forgiving.

Peter

---

<div class="post-metadata">

**Author:** ![nickcamel](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/nickcamel/32/1650_2.png) [@nickcamel](https://discuss.pynq.io/u/nickcamel)\
**Post date:** [March 29, 2021, 4:52pm UTC](https://discuss.pynq.io/t/read-entire-array/2488/3 "2021-03-29T16:52:48Z")

</div>

> [@PeterOgden](#):
>
> my\_ol.mmio.array[0x10:0x20]

Thanks. I know I tried that before but was reading `0`. Now I kept reading through adresses and finally hit some data. It seems addressing of the MMIO it is weird… I read like `0` four times, and on the fifth address (having offset the adresses by 4 each time) I read all four previous values which `read()` returned.

But this is great, I’ll def work on this.  
Thanks again
