MicroBlaze自定义custom IP核实现流水灯(用verilog写的IP逻辑),有实例

参考文档:https://indico.desy.de/indico/event/5126/session/0/contribution/27/material/slides/0.pdf
可以参考这个文档来自己 Adding custom IP,不过这个文档建立的是一个PWM的IP核,并且使用VHDL写的IP逻辑。
这个文档对应官方历程:https://www.avnet.com/shop/us/products/avnet-engineering-services/aes-s6mb-lx9-g-3074457345628965461?aka_re=1
在这里插入图片描述
在这里插入图片描述


我要用verilog写IP逻辑。
与上述文档不同的地方就是:
在这里插入图片描述
三个都选上,其他操作一样。

在建立工程目录中找到这个文件夹
…\pcores…\devl\projnav
打开.xise文件进入IP的ISE工程
在这里插入图片描述
因为我建立的IP叫light_2b,
我要编辑的文件为:
light_2b.vhd
user_logic.v
light_2b_v2_1_0.mpd (这个文件在…\pcores…\data中)

1.light_2b.vhd

上述文件添加代码的地方有三处
– ADD USER PORTS BELOW THIS LINE ------------------
light_out : out std_logic_vector(1 downto 0);
– ADD USER PORTS ABOVE THIS LINE ------------------

– ADD USER PORTS BELOW THIS LINE ------------------
light_out : out std_logic_vector(1 downto 0);
– ADD USER PORTS ABOVE THIS LINE ------------------

– MAP USER PORTS BELOW THIS LINE ------------------
light_out => light_out,
– MAP USER PORTS ABOVE THIS LINE ------------------

2.user_logic.v

这个文件有三处我添加了
// – ADD USER PORTS ABOVE THIS LINE ---------------
light_out,
// – DO NOT EDIT BELOW THIS LINE ------------------

/ – ADD USER PORTS BELOW THIS LINE -----------------
// --USER ports added here
// – ADD USER PORTS ABOVE THIS LINE -----------------
output reg [1:0] light_out;

// USER logic implementation added here
always @( posedge Bus2IP_Clk )
begin
if ( Bus2IP_Resetn == 1’b0 )
light_out <= 2’d0;
else
light_out <= slv_reg0[1:0];
end
// ------------------------------------------------------

3.light_2b_v2_1_0.mpd
这个文件有一处我添加了
##Ports
PORT light_out = “”, DIR = O,VEC = [1:0]


之后步骤还是参考上述那个文档,管脚约束等等。
导入SDK
我建立了Hello Wrold工程

helloworld.c


/*
 * helloworld.c: simple test application
 *
 * This application configures UART 16550 to baud rate 9600.
 * PS7 UART (Zynq) is not initialized by this application, since
 * bootrom/bsp configures it to baud rate 115200
 *
 * ------------------------------------------------
 * | UART TYPE   BAUD RATE                        |
 * ------------------------------------------------
 *   uartns550   9600
 *   uartlite    Configurable only in HW design
 *   ps7_uart    115200 (configured by bootrom/bsp)
 */

#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "xbasic_types.h"

u32 *LED;

int main()
{
	u32 Delay=0;
	LED=(u32 *)XPAR_LIGHT_2B_0_BASEADDR;
    init_platform();
    while(1)
    {
    	*(LED)=0x00000002;
    	for (Delay = 0; Delay < 3000000; Delay++);
    	*(LED)=0x00000001;
    	for (Delay = 0; Delay < 3000000; Delay++);
    }
    return 0;
}

下板,我的板是XC6SLX9
两个灯开始交替闪烁

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值