




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
基于FPGA的四位加法器設(shè)計(jì)4位加法器設(shè)計(jì)。取開發(fā)板上的4位按鍵作為4位被加數(shù),取4位撥碼開關(guān)作為4位被加數(shù),其中8個(gè)led燈取5位作為輸出結(jié)果,led0-led3作為相加的結(jié)果,led4作為進(jìn)位(LED亮表示低電平0,LED滅表示高電平1,)數(shù)碼管以十進(jìn)制數(shù)顯示被加數(shù),加數(shù)和相加的結(jié)果。包括vhdl文件、和vwf文件。利用兩組按鍵作為兩個(gè)加數(shù)輸入,用數(shù)碼管做加數(shù)顯示和結(jié)果顯示,開發(fā)板上只有4個(gè)數(shù)碼管,但加數(shù)都是兩位的,所以只能做輪流顯示,用“=”鍵做顯示切換。程序如下:libraryieee;useieee.std_logic_unsigned.all;useieee.std_logic_1164.all;useieee.std_logic_arith.all;entityadder_4isport( clk:instd_logic;--時(shí)鐘輸入,應(yīng)該輸入分頻后的clk enter:instd_logic;--顯示切換,可以理解位“=”鍵 clear:instd_logic;--清除鍵,預(yù)留接口可擴(kuò)展 key_num1:instd_logic_vector(3downto0);--加數(shù)1 key_num2:instd_logic_vector(3downto0);--加數(shù)2 duan:outstd_logic_vector(6downto0);--輸出結(jié)果 wei:outstd_logic_vector(3downto0); led5:outstd_logic_vector(4downto0)--led結(jié)果顯示 );endentity;architecturefunofadder_4issignalnum1,num2:std_logic_vector(3downto0);--中間信號(hào)定義signaladd_num1:integerrange15downto0;signaladd_num2:integerrange15downto0;signaladd_sum:integerrange30downto0;signalten_data:integerrange9downto0;signaladd_num1ge,add_num1shi,add_num2ge,add_num2shi,sumge,sumshi:integerrange9downto0;signalwei_data:integerrange0to3;begin duan<="1000000"whenten_data=0else--顯示部分,數(shù)碼管共陽(yáng) "1111001"whenten_data=1else "0100100"whenten_data=2else "0110000"whenten_data=3else "0111001"whenten_data=4else "0010010"whenten_data=5else "0000010"whenten_data=6else "1111000"whenten_data=7else "0000000"whenten_data=8else "0010000"; process(clk,clear,enter,key_num1,key_num2,num1,num2,add_num1ge,add_num1shi,add_num2ge,add_num2shi,sumge,sumshi) begin ifclear='0'then add_num1<=0; add_num2<=0; add_sum<=0; else --ifkey_num1/="1111"orkey_num2/="1111"then num1<=notkey_num1; num2<=notkey_num2;--加數(shù)處理,二進(jìn)制轉(zhuǎn)十進(jìn)制。 add_num1<=conv_integer(num1(0))*1+conv_integer(num1(1))*2+conv_integer(num1(2))*4+conv_integer(num1(3))*8;add_num1ge<=(add_num1rem10);--個(gè)位,十位分離 add_num1shi<=((add_num1-add_num1ge)/10); add_num2<=conv_integer(num2(0))*1+conv_integer(num2(1))*2+conv_integer(num2(2))*4+conv_integer(num2(3))*8; add_num2ge<=(add_num2rem10); add_num2shi<=((add_num2-add_num2ge)/10); add_sum<=add_num1+add_num2; sumge<=(add_sumrem10); sumshi<=((add_sum-sumge)/10); led5<=('0'&num1)+('0'&num2); --endif; endif; ifclk'eventandclk='1'then wei_data<=wei_data+1; endif; ifenter='1'then casewei_datais when0=>ten_data<=add_num1ge;wei<="0001"; when1=>ten_data<=add_num1shi;wei<="0010"; when2=>ten_data<=add_num2ge;wei<="0100"; whenothers=>ten_data<=add_num2shi;wei<="1000"; endcase; else casewei_datais when0=>ten_data<=sumge;wei<="0001"; when1=>ten_data<=sumshi;wei<="0010"; when2=>ten_data<=0;wei<="0100"; whenothers=>ten_data<=0;wei<="1000"; endcase; endif; endprocess;endarchitecture;此程序?yàn)椋谡{(diào)試兩周之后的沒有問題的,學(xué)習(xí)班用的CYCLONE_IV_E:以下為50MHZ分頻程序:libraryieee;useieee.std_logic_unsigned.all;useieee.std_logic_1164.all;useieee.std_logic_arith.all;entitydefrequanceisport( in_5khz:instd_logic; out_1hz:outstd_logic );endentitydefrequance;architecturefunofdefrequanceissignalnum:integerrange0to50000;beginprocess(in_5khz,num)beginifin_5khz'eventandin_5khz='1'then num<=num+1; ifnum<25000then-- num<=0; out_1hz<='1'; elsifnum>25000andnum<50000then out_1hz<='0'; endif;endif;endpr
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 高中教師學(xué)期教學(xué)總結(jié)(4篇)
- 法律在我身邊主題精彩演講稿(4篇)
- 初中安全文明小使者事跡材料(3篇)
- 土地租賃合同范文匯編(20篇)
- 武館入學(xué)合同協(xié)議書范本
- 員工分紅入股合同協(xié)議
- 和平協(xié)議書格式
- 員工買賣合同協(xié)議書范本
- 商品混凝土勞動(dòng)合同協(xié)議
- 唐山土地流轉(zhuǎn)合同協(xié)議
- 面試真題華中科技
- CRPS電源設(shè)計(jì)向?qū)?CRPS Design Guide r-2017
- GB/T 9345.1-2008塑料灰分的測(cè)定第1部分:通用方法
- GB/T 3452.2-2007液壓氣動(dòng)用O形橡膠密封圈第2部分:外觀質(zhì)量檢驗(yàn)規(guī)范
- 化工廢氣處理技術(shù)課件
- 四川省自貢市各縣區(qū)鄉(xiāng)鎮(zhèn)行政村村莊村名居民村民委員會(huì)明細(xì)及行政區(qū)劃代碼
- 卷煙廠電氣專業(yè)筆試題
- 小學(xué)勞動(dòng)課《勞動(dòng)安全教育》
- 畸形舌側(cè)溝臨床對(duì)策培訓(xùn)課件
- 標(biāo)準(zhǔn)變壓器用電負(fù)荷計(jì)算表
- DB12∕T 822-2018 路用高粘結(jié)力環(huán)氧乳化瀝青技術(shù)要求
評(píng)論
0/150
提交評(píng)論