版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上SOPC課程設(shè)計實(shí)驗報告 基于SOPC的警示燈設(shè)計 2013電子信息工程3班李婕 羅丹妮一、 設(shè)計目的 1、 熟悉掌握SOPC的基本流程2、 設(shè)計一個警示燈并滿足基本要求3、 通過設(shè)計發(fā)現(xiàn)問題并解決二、 設(shè)計設(shè)備1、硬件:PC機(jī)、SOPC-NIOS II EDA/SOPC系統(tǒng)開發(fā)平臺2、軟件:QUARTUS II、SOPC Builder、NIOS II IDE三、 設(shè)計內(nèi)容 初始狀態(tài)為紅燈(LED2)熄滅,綠燈(LED1)點(diǎn)亮,數(shù)碼管顯示為0。 當(dāng)按鍵按下,紅燈(LED2)閃爍,綠燈(LED1)熄滅,同時蜂鳴器響起,數(shù)碼管開始倒計時9S,此狀態(tài)持續(xù)時間為9s。 9s
2、后,恢復(fù)初始狀態(tài)。四、 設(shè)計步驟1、 使用Quartus II建立一個工程文件和頂層文件;2、 使用SOPC Builder建立一個簡單Nios II硬件系統(tǒng)1) 啟動SOPC Builder2) 指定目標(biāo)FPGA3) 添加NiosII內(nèi)核及其他外設(shè)A、添加NiosII、SRAM、JTAG-UART、Avalon總線的IP核 B、添加一個2位的輸入型PIO作為按鍵keyC、添加兩個1位的輸出型PIO作為 led1及l(fā)ed2的輸出端口D、添加一個1位的輸出型PIO作為蜂鳴器的輸入端口AE、添加一個3位的輸出型PIO作為數(shù)碼管的位選selF、添加一個8位的輸出型PIO作為數(shù)碼管的段選dat 4)
3、指定基地址和中斷優(yōu)先級 5) 設(shè)置NiosII復(fù)位和異常地址6) 編譯生成NiosII系統(tǒng)SOPC Builder行程圖如下:3、在Quartus II中建立一個蜂鳴器 1) 用VHDL語言編寫蜂鳴器程序 2) 編譯成功后Creat symbol,生成Project sing4、在Quartus II中編譯Nios II硬件系統(tǒng)并生成配置文件 1) 在Quartus II加入Nios II系統(tǒng)符號到頂層文件 2) 給各端口加入輸入輸出引腳,并重命名 3) 設(shè)置參數(shù) 4) 編譯頂層文件 5) 分配管腳 6) 再次編譯5、在Nios II IDE中建立C/C+工程,編寫用戶程序6、編譯用戶程序7、
4、下載.SOF至FPGA,運(yùn)行程序,觀察結(jié)果五、設(shè)計程序 蜂鳴器程序(VHDL):LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY sing1 IS PORT( CLK:IN STD_LOGIC; p:IN STD_LOGIC; - DIGIT:BUFFER STD_LOGIC_VECTOR(6 DOWNTO 0); SPEAKER:OUT STD_LOGIC);END ENTITY;ARCHITECTURE SONG OF sing1 ISSIGNAL DRIVER,ORIGIN:ST
5、D_LOGIC_VECTOR(12 DOWNTO 0);SIGNAL COUNTER:INTEGER RANGE 0 TO 140;SIGNAL COUNTER1:INTEGER RANGE 0 TO 3;SIGNAL COUNTER2:INTEGER RANGE 1 TO ;SIGNAL DIGIT :STD_LOGIC_VECTOR(6 DOWNTO 0);SIGNAL COUNT :STD_LOGIC_VECTOR(1 DOWNTO 0); SIGNAL CARRIER,CLK_4MHZ,CLK_4HZ:STD_LOGIC; BEGINPROCESS(CLK)BEGINIF CLK
6、9;EVENT AND CLK='1' THEN IF COUNTER1=1 THEN CLK_4MHZ<='1' COUNTER1<=2; ELSIF COUNTER1=3 THEN CLK_4MHZ<='0' COUNTER1<=0; ELSE COUNTER1<=COUNTER1+1; END IF; IF COUNTER2= THEN CLK_4HZ<='1' COUNTER2<=; ELSIF COUNTER2= THEN CLK_4HZ<='0' COUN
7、TER2<=1; ELSE COUNTER2<=COUNTER2+1; END IF;END IF;END PROCESS;PROCESS(CLK_4MHZ)BEGIN IF CLK_4MHZ'EVENT AND CLK_4MHZ='1' THEN IF DRIVER="11"THEN CARRIER<='1' DRIVER<=ORIGIN;ELSEDRIVER<=DRIVER+1;CARRIER<='0'END IF;END IF;END PROCESS;PROCESS(CARRI
8、ER)BEGINif(p='1')thenIF CARRIER'EVENT AND CARRIER='1' THENCOUNT<=COUNT+1;IF COUNT="00"THENSPEAKER<='1'ELSESPEAKER<='0'END IF;END IF;end if;END PROCESS;PROCESS(CLK_4HZ)BEGINIF CLK_4HZ'EVENT AND CLK_4HZ='1' THEN IF COUNTER=140 THENCOUN
9、TER<=0;ELSE COUNTER<=COUNTER+1;END IF;END IF;CASE COUNTER ISWHEN 0 =>DIGIT<="" WHEN 1 =>DIGIT<=""WHEN 2 =>DIGIT<="" WHEN 3 =>DIGIT<=""WHEN 4 =>DIGIT<="" WHEN 5 =>DIGIT<=""WHEN 6 =>DIGIT<="
10、;" WHEN 7 =>DIGIT<=""WHEN 8 =>DIGIT<="" WHEN 9 =>DIGIT<=""WHEN 10 =>DIGIT<="" WHEN 11 =>DIGIT<=""WHEN 12 =>DIGIT<="" WHEN 13 =>DIGIT<=""WHEN 14 =>DIGIT<="" WHEN 15 =&g
11、t;DIGIT<=""WHEN 16 =>DIGIT<="" WHEN 17 =>DIGIT<=""WHEN 18 =>DIGIT<="" WHEN 19 =>DIGIT<=""WHEN 20 =>DIGIT<="" WHEN 21 =>DIGIT<=""WHEN 22 =>DIGIT<="" WHEN 23 =>DIGIT<=&quo
12、t;"WHEN 24 =>DIGIT<="" WHEN 25 =>DIGIT<=""WHEN 26 =>DIGIT<="" WHEN 27 =>DIGIT<=""WHEN 28 =>DIGIT<="" WHEN 29 =>DIGIT<=""WHEN 30 =>DIGIT<="" WHEN 31 =>DIGIT<=""WHEN 32
13、=>DIGIT<="" WHEN 33 =>DIGIT<=""WHEN 34 =>DIGIT<="" WHEN 35 =>DIGIT<=""WHEN 36 =>DIGIT<="" WHEN 37 =>DIGIT<=""WHEN 38 =>DIGIT<="" WHEN 39 =>DIGIT<=""WHEN 40 =>DIGIT<=&
14、quot;" WHEN 41 =>DIGIT<=""WHEN 42 =>DIGIT<="" WHEN 43 =>DIGIT<=""WHEN 44 =>DIGIT<="" WHEN 45 =>DIGIT<=""WHEN 46 =>DIGIT<="" WHEN 47 =>DIGIT<=""WHEN 48 =>DIGIT<="" WHEN
15、 49 =>DIGIT<=""WHEN 50 =>DIGIT<="" WHEN 51 =>DIGIT<=""WHEN 52 =>DIGIT<="" WHEN 53 =>DIGIT<=""WHEN 54 =>DIGIT<="" WHEN 55 =>DIGIT<=""WHEN 56 =>DIGIT<="" WHEN 57 =>DIGIT&l
16、t;=""WHEN 58 =>DIGIT<="" WHEN 59 =>DIGIT<=""WHEN 60 =>DIGIT<="" WHEN 61 =>DIGIT<=""WHEN 62 =>DIGIT<="" WHEN 63 =>DIGIT<=""WHEN 64 =>DIGIT<="" WHEN 65 =>DIGIT<=""W
17、HEN 66 =>DIGIT<="" WHEN 67 =>DIGIT<=""WHEN 68 =>DIGIT<="" WHEN 69 =>DIGIT<=""WHEN 70 =>DIGIT<="" WHEN 71 =>DIGIT<=""WHEN 72 =>DIGIT<="" WHEN 73 =>DIGIT<=""WHEN 74 =>DIGI
18、T<="" WHEN 75 =>DIGIT<=""WHEN 76 =>DIGIT<="" WHEN 77 =>DIGIT<=""WHEN 78 =>DIGIT<="" WHEN 79 =>DIGIT<=""WHEN 80 =>DIGIT<="" WHEN 81 =>DIGIT<=""WHEN 82 =>DIGIT<="&quo
19、t; WHEN 83 =>DIGIT<=""WHEN 84 =>DIGIT<="" WHEN 85 =>DIGIT<=""WHEN 86 =>DIGIT<="" WHEN 87 =>DIGIT<=""WHEN 88 =>DIGIT<="" WHEN 89 =>DIGIT<=""WHEN 90 =>DIGIT<="" WHEN 91 =>
20、DIGIT<=""WHEN 92 =>DIGIT<="" WHEN 93 =>DIGIT<=""WHEN 94 =>DIGIT<="" WHEN 95 =>DIGIT<=""WHEN 96 =>DIGIT<="" WHEN 97 =>DIGIT<=""WHEN 98 =>DIGIT<="" WHEN 99 =>DIGIT<="
21、"WHEN 100=>DIGIT<="" WHEN 101=>DIGIT<=""WHEN 102=>DIGIT<="" WHEN 103=>DIGIT<=""WHEN 104=>DIGIT<="" WHEN 105=>DIGIT<=""WHEN 106=>DIGIT<="" WHEN 107=>DIGIT<=""WHEN 108=&
22、gt;DIGIT<="" WHEN 109=>DIGIT<=""WHEN 110=>DIGIT<="" WHEN 111=>DIGIT<=""WHEN 112=>DIGIT<="" WHEN 113=>DIGIT<=""WHEN 114=>DIGIT<="" WHEN 115=>DIGIT<=""WHEN 116=>DIGIT<=&qu
23、ot;" WHEN 117=>DIGIT<=""WHEN 118=>DIGIT<="" WHEN 119=>DIGIT<=""WHEN 120=>DIGIT<="" WHEN 121=>DIGIT<=""WHEN 122=>DIGIT<="" WHEN 123=>DIGIT<=""WHEN 124=>DIGIT<="" WHEN 1
24、25=>DIGIT<=""WHEN 126=>DIGIT<="" WHEN 127=>DIGIT<=""WHEN 128=>DIGIT<="" WHEN 129=>DIGIT<=""WHEN 130=>DIGIT<="" WHEN 131=>DIGIT<=""WHEN 132=>DIGIT<="" WHEN 133=>DIGIT<
25、=""WHEN 134=>DIGIT<="" WHEN 135=>DIGIT<=""WHEN 136=>DIGIT<="" WHEN 137=>DIGIT<=""WHEN 138=>DIGIT<="" WHEN 139=>DIGIT<=""WHEN OTHERS=>DIGIT<=""END CASE;CASE DIGIT IS WHEN "&q
26、uot;=>ORIGIN<="00" WHEN ""=>ORIGIN<="01" WHEN ""=>ORIGIN<="10" WHEN ""=>ORIGIN<="01" WHEN ""=>ORIGIN<="01" WHEN ""=>ORIGIN<="10" WHEN ""=>ORI
27、GIN<="01" WHEN ""=>ORIGIN<="00" WHEN ""=>ORIGIN<="10" WHEN ""=>ORIGIN<="00"WHEN OTHERS=>ORIGIN<="11"END CASE;END PROCESS;END SONG; 警示燈總程序:#include <stdio.h> #include <sys/unistd.h>
28、#include <io.h> #include <string.h> #include "system.h" #include "altera_avalon_pio_regs.h" #include "alt_types.h" #include "sys/alt_irq.h" int num;static void Button_ISR_Init(void);static void Button_Irq_Handler(void* context,alt_u32 id);alt_u8 se
29、gtab10=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f; /09段碼static void display(int num);/按鍵初始化static void Button_ISR_Init(void) IOWR_ALTERA_AVALON_PIO_IRQ_MASK(KEY_BASE,0xff); /允許8個按鍵中斷 IOWR_ALTERA_AVALON_PIO_EDGE_CAP(KEY_BASE,0); /清除中斷標(biāo)志寄存器 alt_irq_register(KEY_IRQ,NULL,Button_Irq_Handler); /注冊中斷 static void display(int num) IOWR_ALTERA_AVALON_PIO_DATA(SEL_BASE,0); /數(shù)碼管位選 IOWR_ALTERA_AVALON_PIO_DATA(DAT_BASE,segtabnum); /顯示倒計時 usle
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 改擴(kuò)建工程施工合同的融資方案3篇
- 插畫師勞動合同樣本3篇
- 散熱器招標(biāo)文件的合同簽訂流程指導(dǎo)3篇
- 教育培訓(xùn)項目中標(biāo)合同3篇
- 旅游大巴車租賃合同范本3篇
- 放心供應(yīng)商零件訂購合同3篇
- 工業(yè)烤箱安裝工程合同書3篇
- 工業(yè)往來貸款協(xié)議3篇
- 房屋買賣委托書填寫指南3篇
- 旅游合同范本集合3篇
- 青年應(yīng)有鴻鵠志當(dāng)騎駿馬踏平川課件高三上學(xué)期勵志主題班會
- 河北省唐山市2021-2022學(xué)年高三上學(xué)期語文期末試卷
- 華電甘肅能源有限公司華電系統(tǒng)內(nèi)外招聘真題
- 員工宿舍管理條例
- 雙減背景下基于核心素養(yǎng)小學(xué)語文閱讀提升實(shí)踐研究結(jié)題報告
- 2024應(yīng)急預(yù)案編制導(dǎo)則
- 新疆大學(xué)答辯模板課件模板
- 數(shù)值分析智慧樹知到期末考試答案2024年
- 2024年浙江省新華書店集團(tuán)招聘筆試參考題庫附帶答案詳解
- 跨文化溝通心理學(xué)智慧樹知到期末考試答案2024年
- 預(yù)制梁場建設(shè)驗收標(biāo)準(zhǔn)
評論
0/150
提交評論