日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

自定义IP原来如此简单

發(fā)布時間:2025/4/16 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 自定义IP原来如此简单 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

首先用Verilog語言或者VHDL編寫、或者用原理圖來畫硬件驅動,以數(shù)碼管驅動為例子,編寫Verilog如下:

1 module sg7IP(
2
3 ?input reset,
4 ?input clk,
5 ?input avs_s1_write,
6 ?input [31:0]avs_s1_writedata,
7 ?input avs_s1_address,
8 ?output wire [7:0] oSEG7
9 );
10
11 ?reg [7:0] sg7_r;
12 ?always @(posedge clk or posedge reset)
13 begin
14 if(reset)
15 sg7_r<=8'hf;
16 else if(avs_s1_write&&avs_s1_address==0)
17 sg7_r[7:0]<=avs_s1_writedata[7:0];
18
19 end
20 assign oSEG7=~sg7_r;
21 endmodule
22

?

?

然后編寫一個頂層文件來調用sg7IP.v來測試驗證上面的驅動是正常的。我這里編寫了sg7top.v來作為頂層文件。

?

1 module seg7top(
2 input iCLK_50,
3 input [0:0]iKEY,
4 output wire [6:0] oHEX0_D,
5 output wire oHEX0_DP
6 );
7
8
9 sg7IP sg7ipu0(
10 .reset(!iKEY[0]),
11 .clk(iCLK_50),
12 .avs_s1_write(1'b1),
13 .avs_s1_writedata(32'd113),
14 .avs_s1_address(1'b0),
15 .oSEG7({oHEX0_DP,oHEX0_D[6:0]})
16

17 endmodule
18

分配管教,編譯后下載到DE2-70的開發(fā)板中,數(shù)碼管HEX0顯示為F則表示硬件驅動正常。

?

?

然后打開SOPCBuilder,新建一個component。過程如下圖。

?

?

?

添加sg7IP、onchipmemory、cpu、jtag uart組件,點擊“生成”

?

?

完了后在QUARTUS II中修改sg7top.v

?

?

?

1 module seg7top(
2 input iCLK_50,
3 input [0:0]iKEY,
4 output wire [6:0] oHEX0_D,
5 output wire oHEX0_DP
6 );
7
8
9 nios_cpu nios_cpu_inst
10 (
11 .clk_0 (iCLK_50),
12 .oSEG7_from_the_sg7IP_0 ({oHEX0_DP,oHEX0_D[6:0]}),
13 .reset_n (iKEY[0])
14 );
15
16 endmodule
17

?

?

重新編譯,下載。

打開NISO IDE。

新建空工程。

建立sg7.h

?

?

1 #ifndef SEG7_H_
2 #define SEG7_H_
3
4 void SEG7_NUM(alt_u8 num);
5
6
7 #endif /*SEG7_H_*/
8

?

?

建立sg7.c

?

?

1 #include "io.h"
2 #include "alt_types.h"
3
4 #include "system.h"
5
6 #include "SEG7.h"
7
8 #define SEG7_SET(seg_mask) IOWR(SG7IP_0_BASE,0,seg_mask)
9
10 static unsigned char szMap[] = {
11 63, 6, 91, 79, 102, 109, 125, 7,
12 127, 111, 119, 124, 57, 94, 121, 113
13 }; // 0,1,2,....9, a, b, c, d, e, f
14
15
16 void SEG7_NUM(alt_u8 num)
17 {
18 SEG7_SET(szMap[num]);
19 }
20

?

建立main.c

?

1 #include <stdio.h>
2 #include "system.h"
3 #include "unistd.h"
4 #include "alt_types.h"
5 #include "SEG7.h"
6
7 int main(void) {
8 alt_u8 i=0;
9 printf("My first IP");
10 while(1){
11 for(i = 0; i <10; i++) {
12 SEG7_NUM(i);
13 printf("Now print:%d\n",i);
14 usleep(1 * 1000 * 1000);
15 }
16 }
17 return 0;
18 }
19

CTRL+B編譯。

run as? NIOS II? hardware。

開發(fā)板中的數(shù)碼管從0到9不斷變化。IP編寫測試完畢。

轉載于:https://www.cnblogs.com/nios_ii/archive/2010/10/05/1844432.html

《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的自定义IP原来如此简单的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。