UG1085第十八章给出OCM的地址信息:
首先新建一个AXI-FULL的IP,设置基地址为0xFFFC0000,
写数据修改为利于观察的数据:
/* Write Data Generator
Data pattern is only a simple incrementing count from 0 for each burst */
always @(posedge M_AXI_ACLK)
begin
if (M_AXI_ARESETN == 0 || init_txn_pulse == 1'b1)
axi_wdata <= 32'd0;
//else if (wnext && axi_wlast)
// axi_wdata <= 'b0;
else if (wnext)
if(axi_wdata == 32'hFFFFFFFF)
axi_wdata <= 32'h00000000;
else
axi_wdata <= axi_wdata + 32'h11111111;
// axi_wdata <= axi_wdata + 1;
else
axi_wdata <= axi_wdata;
end
打开zynq中的HP0接口,并设置地址信息:
工程BD:
在vitis中新建helloworld工程,需要关闭CPU Cache功能,代码如下:
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "sleep.h"
#include "xil_io.h"
#include "xil_cache.h"
int main()
{
init_platform();
Xil_DCacheDisable();
Xil_ICacheDisable();
int cnt = 0;
while(1){
sleep(1);
print("Hello World\n\r");
printf("num:%d --- %lx\n\r",cnt,Xil_In32(0xFFFC0000+cnt*4));
if(cnt == 15){
cnt = 0;
} else{
cnt = cnt + 1;
}
}
print("Successfully ran Hello World application");
cleanup_platform();
return 0;
}
打开memory界面即可看到PL端写进去的数据:
串口打印: