1. 程式人生 > >MicroBlaze自定義custom IP核實現流水燈(用verilog寫的IP邏輯),有例項

MicroBlaze自定義custom IP核實現流水燈(用verilog寫的IP邏輯),有例項

我要用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
兩個燈開始交替閃爍