Jean-Christophe Owens
Published

Super96s Clusters - Part 3

Creating a series of modules allowing you to connect for the first time a PYNQ acceleration distribution network for edge devices U96.

AdvancedFull instructions provided3 hours179
Super96s Clusters - Part 3

Things used in this project

Story

Read more

Code

Vitis Overlay

Python
# coding: utf-8

# In[88]:


from pynq import Overlay
import time
from pynq import allocate
from pynq.lib.dma import DMA
import numpy as np
# from PIL import Image
from IPython.display import Image
import matplotlib.pyplot as plt


# In[89]:


# Import libs 
from pynq import Overlay 
from pynq import Device
from pynq import DefaultIP


# In[87]:


for i in range(len(pynq.Device.devices)):
    print("{}) {}".format(i, pynq.Device.devices[i].name))


# In[90]:


overlay_1 = Overlay("bitfile_hwh_files/vitis_accel_add.xclbin", device=pynq.Device.devices[1])
get_ipython().magic('pinfo overlay_1')


# In[75]:


#-----------------------
#Bring the bit file in [Do Not NEED]
#-----------------------

# overlay_1 = pynq.Overlay('my_overlay1.bit', device=pynq.Device.devices[0])


# overlay_1 = Overlay("bitfile_hwh_files/test_2.bit")
# overlay_1?

# overlay_2 = Overlay("bitfile_hwh_files/test_3.bit")
# help(overlay_2)

# overlay_3 = Overlay("bitfile_hwh_files/vitis_accel_add.bit")
# overlay_3?

# overlay = Overlay("test_2.xclbin", device=pynq.Device.devices[1])
# overlay?


# In[91]:


# Creating a driver for the new kernel function vadd
# Verify you can run this Ip
add_ip = overlay_1.krnl_vadd_1          
# add_ip?


# In[92]:


add_ip.register_map


# # Load in the allocation lib

# In[93]:


#Running xrt accelerator code
import pynq
from pynq import allocate

# INITIALIZE - Allocation arroay of at least 5 32 integers
input_buf_1 = pynq.allocate(shape=(4,), dtype='u4')
input_buf_2 = pynq.allocate(shape=(4,), dtype='u4')

#output
outbuf_1 = pynq.allocate(shape=(4,), dtype='u4')
# outbuf_2 = pynq.allocate(shape=(4,), dtype='u4')

#initialize the buffers
for i in range(4):
    input_buf_1 [i] = i
    input_buf_2 [i] = i + 1
    
# Write to size
# add_ip.register_map.size = 4


# In[94]:


print(input_buf_1)
print(input_buf_2)


# In[95]:


add_ip.register_map


# ## Sync to Device & Start Kernel Call

# In[96]:


#XRT Framework
input_buf_1.sync_to_device()
input_buf_2.sync_to_device()


# In[82]:


# Input 1 | input 2 | output | size
overlay_1.krnl_vadd_1.call(input_buf_1, input_buf_2, outbuf_1, 4)


# In[97]:


#Send the data XRT - START
handle = overlay_1.krnl_vadd_1.start(input_buf_1, input_buf_2, outbuf_1, 4)
handle.wait()


# In[98]:


outbuf_1.sync_from_device()


# In[99]:


outbuf_1


# # ----- END of DOCUMENT ------

Credits

Jean-Christophe Owens

Jean-Christophe Owens

8 projects • 16 followers
Just a rogue hacker! Love to make embedded-related projects, playing mostly with Xilinx tools, Vivado and Vitis. Love making and inventing!
Thanks to Adam Taylor.

Comments