ZynqMPSoC PL端访问OCM

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端写进去的数据:

 串口打印:

        

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值