Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Dimiter Kendri
Published © GPL3+

Porting PYNQ to ZC702

Porting PYNQ to the ZC702 offical development board.

IntermediateFull instructions providedOver 1 day2,082
Porting PYNQ to ZC702

Things used in this project

Hardware components

ZC702
AMD ZC702
×1

Software apps and online services

Vivado Design Suite
AMD Vivado Design Suite
PYNQ
Vivado Design Suite HLx Editions
AMD Vivado Design Suite HLx Editions

Story

Read more

Schematics

BRAM schematics on ZC702

Vivado BRAM schematics on ZC702

Code

BRAM_test.py

Python
Read and write BRAM from PYNQ
# author: dhq 
# Date Dec 2019

# coding: utf-8

# In[1]:


from PIL import Image
import numpy as np
from IPython.display import display
from pynq import Xlnk
from pynq import Overlay


# ## Download the BRAM IP 

# In[2]:


BRAM_design = Overlay("pynqbram.bit")


# In[3]:


get_ipython().magic('pinfo BRAM_design')


# #### Create DMA and Resizer IP objects

# In[9]:


bram = BRAM_design.axi_bram_ctrl_0
#gpio = BRAM_design.axi_gpio_0


# ## Check HW 

# In[5]:


BRAM_design.ip_dict


# In[6]:


from pynq.lib import AxiGPIO
led_instance = BRAM_design.ip_dict['axi_gpio_0']
led = AxiGPIO(led_instance).channel1


# In[ ]:


led.write(0x0)
base.btns_gpio.read()


# In[10]:




BASE_ADDRESS = 0x40000000
        
from pynq import MMIO
  
class BRAM:
    """Brief description of Module goes here.
    
    Attributes
    ----------
    array_size : int
       Describe  parameters used in this module's functions.
    raw_data : int
       Input Data
    processed_data : int
       Return data
       
   """
    mmio = MMIO(BASE_ADDRESS,BASE_ADDRESS+0x00000FFF)
    array_length = 0
 
    def __init__(self):
        self.mmio.write(0, 0)
     
    def load_data(self, raw_data):
        self.array_length = len(raw_data)
        for i in range(0 , self.array_length):
            self.mmio.write(i*4, raw_data[i])
            
    def read_data(self):     
        processed_data = [0] *self.array_length

        for i in range(0 , self.array_length):
            processed_data[i] = self.mmio.read(i*4)
        return processed_data


# In[11]:


# declare acc with a Maximum allowable array size
acc = BRAM()
raw_data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
#print("Some data to be sent to the accelerator:", raw_data)
acc.load_data(raw_data)
processed_data = acc.read_data()
print("Input Data     : ", raw_data)
print("Processed Data : ", processed_data)


# In[12]:


import random
array_length = len(raw_data)
for i in range (0 , array_length):
    raw_data[i] = random.randint(0, 32767)
acc.load_data(raw_data)
processed_data = acc.read_data()
print("Input Data     : ", raw_data)
print("Processed Data : ", processed_data)

Credits

Dimiter Kendri
23 projects • 163 followers
Robotics and AI
Contact

Comments

Please log in or sign up to comment.