版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、北郵數(shù)電實(shí)驗(yàn)VHDL源代碼完整版注:北郵信通院數(shù)電實(shí)驗(yàn),大二下共四次實(shí)驗(yàn),以下為四次實(shí)驗(yàn)的完整代碼,僅供參考,希望學(xué)弟學(xué)妹在抄代碼的時(shí)候了解每一行代碼的含義。知識是自己的。別忘了,北郵的未來靠你們。注意事項(xiàng):1學(xué)校部分電腦打不開07版word文件(后綴docx),建議大家準(zhǔn)備一份TXT以防萬一2運(yùn)行出錯(cuò)時(shí)可能是你輸入有誤,比如中文和英文符號弄錯(cuò)了3數(shù)電實(shí)驗(yàn)很簡單,但要心細(xì),一定要按老師說的做4數(shù)電實(shí)驗(yàn)報(bào)告千萬不要抄襲,老師判斷力很強(qiáng)實(shí)驗(yàn)一:半加器老師會給出,全加器是畫圖,怎么畫書上有,不用源代碼。實(shí)驗(yàn)二:(1)3位二進(jìn)制數(shù)比較器LIBRARY IEEE;USE IEEE.STD_LOGIC_1
2、164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY comp3 IS PORT(A:IN STD_LOGIC_VECTOR(2 DOWNTO 0); B:IN STD_LOGIC_VECTOR(2 DOWNTO 0); YA,YB,YC:OUT STD_LOGIC);END comp3;ARCHITECTURE behave OF comp3 ISBEGIN PROCESS(A,B) BEGIN IF(AB)THEN YA=1;YB=0;YC=0; ELSIF(AB)THEN YA=0;YB=1;YC=0; ELSE YA=0;YB=0;YC Y=D0
3、;YB Y=D1;YB Y=D2;YB Y=D3;YB Y=Z;YB=Z; END CASE; END PROCESS;END behave;(3)8421碼轉(zhuǎn)換為格雷碼LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY trans1 ISPORT(A:IN STD_LOGIC_VECTOR(3 DOWNTO 0); B:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);END trans1;ARCHITECTURE trans_gray OF trans1 ISBEGI
4、NB(0)=A(0)XOR A(1);B(1)=A(1)XOR A(2); B(2)=A(2)XOR A(3);B(3) B B B B B B B B B B B=ZZZZ;END CASE;END PROCESS;END trans_ex3;(5)數(shù)碼管譯碼器LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY sunyu_encoder ISPORT(A:IN STD_LOGIC_VECTOR(3 DOWNTO 0); B:OUT STD_LOGIC_VECTOR(6 DOWNTO
5、0); C:OUT STD_LOGIC_VECTOR(5 DOWNTO 0);END sunyu_encoder;ARCHITECTURE encoder_arch OF sunyu_encoder ISBEGINPROCESS(A)BEGINC B B B B B B B B B B B=ZZZZZZZ;END CASE;END PROCESS;END encoder_arch;實(shí)驗(yàn)三:注:以下的AAA(1)(2)(3)(4)為課前做好的,但課上老師要求有了些變化,實(shí)際上機(jī)的代碼在下面BBB中AAA(1)帶異步復(fù)位的四位二進(jìn)制減計(jì)數(shù)器LIBRARY IEEE;USE IEEE.STD_LOG
6、IC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY count_1 ISPORT(clk,reset:IN STD_LOGIC;q:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);END count_1;ARCHITECTURE a OF count_1 ISSIGNAL q_temp:STD_LOGIC_VECTOR(3 DOWNTO 0);BEGINPROCESS(clk,reset)BEGINIF reset=0 THENq_temp =1111;ELSIF clkEVENT AND clk=1 THENq_temp =
7、q_temp-1;END IF;END PROCESS;q= q_temp;END a;(2)帶異步復(fù)位的8421碼十進(jìn)制計(jì)數(shù)器LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY count_BCD ISPORT(clk,reset:IN STD_LOGIC;q:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);END count_BCD;ARCHITECTURE a OF count_BCD ISSIGNAL q_temp:STD_LOGIC_VECTOR(3 DOWN
8、TO 0);BEGINPROCESS(clk,reset)BEGINIF reset=0 THENq_temp =0000;ELSIF clkEVENT AND clk=1 THENIF q_temp=1001 THENq_temp =0000;ELSE q_temp =q_temp+1;END IF;END IF;END PROCESS;q= q_temp;END a;(3)分頻器LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY div_12 ISPORT(clk:IN STD_LO
9、GIC;clear:IN STD_LOGIC;clk_out:OUT STD_LOGIC);END div_12;ARCHITECTURE a OF div_12 ISSIGNAL temp:INTEGER RANGE 0 TO 11;BEGINp1:PROCESS(clear,clk)BEGINIF clear=0THENtemp=0;ELSIF clkEVENT AND clk=1 THENIF temp=11 THENtemp=0;ELSE temp=temp+1;END IF;END IF;END PROCESS p1;p2:PROCESS(temp)BEGINIF temp6 THE
10、Nclk_out=0;ELSE clk_out=1;END IF;END PROCESS p2;END a;(4)帶異步復(fù)位的四位環(huán)形計(jì)數(shù)器LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY ring ISPORT(clk,reset:IN STD_LOGIC;countout:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);END ring;ARCHITECTURE behave OF ring ISSIGNAL nextcount:STD_LOGIC_VECTOR(
11、3 DOWNTO 0);BEGINPROCESS(clk,reset) -0001-0010-0100-1000-0001BEGINIF reset=0 THEN nextcount nextcount nextcount nextcount nextcount=0001;END CASE;END IF;END PROCESS;countout=nextcount;END behave;BBBLIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY count_BCD ISPORT(clk,r
12、eset:IN STD_LOGIC;q:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);END count_BCD;ARCHITECTURE a OF count_BCD ISSIGNAL q_temp:STD_LOGIC_VECTOR(3 DOWNTO 0);BEGINPROCESS(clk,reset)BEGINIF reset=1 THENq_temp =0000;ELSIF clkEVENT AND clk=1 THENIF q_temp=1001 THENq_temp =0000;ELSE q_temp =q_temp+1;END IF;END IF;END PRO
13、CESS;q= q_temp;END a;LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY ring ISPORT(clk,reset:IN STD_LOGIC;-clk_out:out STD_LOGIC;countout:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);END ring;ARCHITECTURE behave OF ring ISSIGNAL nextcount:STD_LOGIC_VECTOR(3 DOWNTO 0);SIGNAL temp:ST
14、D_LOGIC;BEGINp1:PROCESS(clk)VARIABLE count:integer range 0 to 25000000;BEGINIF( clkEVENT AND clk=1 )THENIF (count=25000000) THENcount:=0;temp=not temp;ELSE count:=count+1;END IF;END IF;END PROCESS p1;-clk_out=temp;p2:PROCESS(temp,reset) -0001-0010-0100-1000-0001BEGINIF reset=1 THEN nextcount nextcou
15、nt nextcount nextcount nextcount=0001;END CASE;END IF;END PROCESS p2;countout=nextcount;END behave;LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY div_12new ISPORT(clk:IN STD_LOGIC;clear:IN STD_LOGIC;clk_out:OUT STD_LOGIC);END div_12new;ARCHITECTURE a OF div_12new ISS
16、IGNAL temp:STD_LOGIC;BEGINPROCESS(clear,clk)VARIABLE count:integer range 0 to 5;BEGINif (clear=1) thencount:=0;ELSIF( clkEVENT AND clk=1 )THENIF (count=5) THENcount:=0;temp=not temp;ELSE count:=count+1;END IF;END IF;END PROCESS;clk_out=temp;END a;實(shí)驗(yàn)四:這個(gè)稍有難度,而且書上沒有多少參考代碼,仔細(xì)研究哦(1)數(shù)碼管顯示012345library ie
17、ee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity nixietube1 isport(clk: in std_logic;partout:out std_logic_vector(6 downto 0);catout: out std_logic_vector(5 downto 0);end nixietube1;architecture a of nixietube1 issignal part: std_logic_vector(6 downto 0);signal cat: std_logic_ve
18、ctor(5 downto 0);signal tempclk: std_logic;signal count: integer range 0 to 50000;beginp1:process(clk)beginif(clkevent and clk=1)thenif count=50000 thencount=0;tempclk= not tempclk;elsecount cat=011111;part cat=101111;part cat=110111;part cat=111011;part cat=111101;part cat=111110;part cat=011111;pa
19、rt=1111110; -0end case;end if;end process p2;catout=cat;partout=part;end a;(2)數(shù)碼管滾動(dòng)顯示012345library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity shiyan12new2 isport(clk: in std_logic;partout:out std_logic_vector(6 downto 0);catout: out std_logic_vector(5 downto 0);end shiya
20、n12new2;architecture a of shiyan12new2 issignal part: std_logic_vector(6 downto 0);signal cat: std_logic_vector(5 downto 0);signal number: std_logic_vector(5 downto 0);signal tempclk: std_logic;-a clk(div 1)signal move: std_logic;-a clk(div 2)beginp1:process(clk)-div 1 (cat 0-5)variable count:intege
21、r range 0 to 50000:=0;beginif(clkevent and clk=1)thenif(count=50000)thencount:=0;tempclkcatcatcatcatcatcat=011111;end case;end if;end process p2;catout=cat;p3:process(clk)-div 2 (one cat and change) about 1Hzvariable count:integer range 0 to 25000000:=0;beginif (clkevent and clk=1) thenif (count=250
22、00000) thencount:=0;movenumbernumbernumbernumbernumbernumbernumbernumbernumbernumbernumbernumberpartpartpartpartpartpartpart=1111110;end case;end process p5;partout=part;end a;(3)數(shù)碼管滾動(dòng)顯示012345,且用全滅的數(shù)碼管填充右邊,直至全滅library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity shiyan12ne
23、w3 isport(clk: in std_logic;partout:out std_logic_vector(6 downto 0);catout: out std_logic_vector(5 downto 0);end shiyan12new3;architecture a of shiyan12new3 issignal part: std_logic_vector(6 downto 0);signal cat: std_logic_vector(5 downto 0);signal number: std_logic_vector(5 downto 0);signal tempclk: std_logic;-a clk(d
溫馨提示
- 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年簡化版建筑工程協(xié)議范例版B版
- 煤層注水課程設(shè)計(jì)
- 換熱器課程設(shè)計(jì)前言
- 直播引流課程設(shè)計(jì)技巧
- 承德醫(yī)學(xué)院《漢語應(yīng)用文寫作》2023-2024學(xué)年第一學(xué)期期末試卷
- 成都中醫(yī)藥大學(xué)《價(jià)值評估》2023-2024學(xué)年第一學(xué)期期末試卷
- 成都藝術(shù)職業(yè)大學(xué)《綜合評價(jià)》2023-2024學(xué)年第一學(xué)期期末試卷
- 2024煤礦用工承包合同-勞動(dòng)保護(hù)用品提供與維護(hù)3篇
- 《第六枚戒指》劉麗英:揭示現(xiàn)代婚戀中的真相與假象
- 2025年度白酒行業(yè)供應(yīng)鏈金融服務(wù)合同6篇
- DL-T 2231-2021 油紙絕緣電力設(shè)備頻域介電譜測試導(dǎo)則
- 員工月度績效考核管理辦法
- 2023年云南保山電力股份有限公司招聘筆試題庫及答案解析
- GB/T 41904-2022信息技術(shù)自動(dòng)化基礎(chǔ)設(shè)施管理(AIM)系統(tǒng)要求、數(shù)據(jù)交換及應(yīng)用
- GB/T 41908-2022人類糞便樣本采集與處理
- GB/T 3745.1-1983卡套式三通管接頭
- 信息系統(tǒng)運(yùn)維服務(wù)方案
- 簡支梁、懸臂梁撓度計(jì)算程序(自動(dòng)版)
- DB44∕T 2149-2018 森林資源規(guī)劃設(shè)計(jì)調(diào)查技術(shù)規(guī)程
- 統(tǒng)編版小學(xué)四年級語文上冊五六單元測試卷(附答案)
- 商票保貼協(xié)議
評論
0/150
提交評論