硬件配置:在vivado的设计中,每次点击pynq的按键后,创建的ip核将通过AXI4 Master端口向Slave端指定的4K存储空间中连续写入1024个数据,每个数据占32bit。DDR的起始地址为 0x10000000 ,
from pynq import Overlay
from pynq import Xlnk
import numpy as np
from pynq import MMIO
axi4_ddr = Overlay("./ready_to_test/axi4_ddr.bit")
xlnk = Xlnk()
buf = xlnk.cma_array(shape=(1024,), dtype=np.uint32, cacheable=0)
addr = buf.physical_address
ctrl = MMIO(0x10000000, 0x1000)# 开辟一块区域可供用户读写,主要是对寄存器(slave)的读写,(起始地址,字节长度)
#数据读取
for i in range(0,4096,4):
a = ctrl.read(i,4) # 读寄存器(偏移,字长) 32位宽数据一个数据4个字节
print(a)
#数据写入
for i in range(0,4096,4):
ctrl.write(i,i) # 写寄存器(偏移,数值)