




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、VHDL程序設(shè)計題四、 編程題(共50分)1、請補全以下二選一VHDL程序(本題10分)Entity mux isport(d0,d1,sel:in bit;q:out BIT ); (2)end mux;architecture connect of MUX is (4) signal tmp1, TMP2 ,tmp3:bit; (6)begin cale:block begin tmp1<=d0 and sel; tmp2<=d1 and (not sel) tmp3<= tmp1 and tmp2;q <= tmp3; (8) end block cale; en
2、d CONNECT ; (10)2、編寫一個2輸入與門的VHDL程序,請寫出庫、程序包、實體、構(gòu)造體相關(guān)語句,將端口定義為標(biāo)準邏輯型數(shù)據(jù)結(jié)構(gòu)(本題10分)&abyLIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; (2) ENTITY nand2 IS PORT (a,b:IN STD_LOGIC; (4) y:OUT STD_LOGIC); (6) END nand2; ARCHITECTURE nand2_1 OF nand2 IS (8) BEGIN y <= a NAND b; -與y <=NOT( a AND b);等價 (10)
3、 END nand2_1;3、根據(jù)下表填寫完成一個3-8線譯碼器的VHDL程序(16分)。LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY decoder_3_to_8 IS PORT (a,b,c,g1,g2a,g2b:IN STD_LOGIC; y:OUT STD_LOGIC_VECTOR(7 DOWNTO 0); (2)END decoder_3_to_8;ARCHITECTURE rtl OF decoder_3_to_8 IS SIGNAL indata:STD_LOGIC_VECTOR (2 DOWNTO 0);(4)BEGIN ind
4、ata <= c & b & a;(6)PROCESS (indata,g1,g2a,g2b) BEGIN IF (g1 = '1' AND g2a = '0' AND g2b = '0' ) THEN (8) CASE indata IS WHEN "000"=> y <= "11111110" WHEN "001" => y <= "11111101" WHEN "010" => y <
5、= "11111011"(10) WHEN "011" => y <= "11110111" WHEN "100" => y <= "11101111" WHEN "101" => y <= "11011111" WHEN "110" => y <= "10111111" (12) WHEN "111" => y <= "011
6、11111" WHEN OTHERS=> y <= "XXXXXXXX" END CASE; ELSE y <= "11111111"(14) END IF; END PROCESS;(16)END rtl; 4、三態(tài)門電原理圖如右圖所示,真值表如左圖所示,請完成其VHDL程序構(gòu)造體部分。(本題14分)LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL;ENTITY tri_gate ISPORT(din,en:IN STD_LOGIC; dout : OUT STD_LOGIC);END tr
7、i_gate ;ARCHITECTURE zas OF tri_gate ISBEGIN PROCESS (din,en) BEGINIF (en=1') THEN dout <= din;ELSE dout <= Z; END IF; END PROCESS ;END zas ;四、 編程題(共50分)1、根據(jù)一下四選一程序的結(jié)構(gòu)體部分,完成實體程序部分(本題8分)entity MUX4 is port( (2)s:in std_logic_vector(1 downto 0); (4)d:in std_logic_vector(3 downto 0); (6)y:out
8、 std_logic (8); end MUX4; architecture behave of MUX4 isbeginprocess(s)beginif (s="00") theny<=d(0); elsif (s="01") theny<=d(1); elsif (s="10") theny<=d(2); elsif (s="11") theny<=d(3); elsenull; end if;end process;end behave; 2、編寫一個數(shù)值比較器VHDL程序的進程(不
9、必寫整個結(jié)構(gòu)框架),要求使能信號g低電平時比較器開始工作,輸入信號p = q,輸出equ為0,否則為1。(本題10分)process(p,q)(2)beginif g='0' then(4)if p = q thenequ <= '0' (6)else equ <= '1' (8)end if;else equ <= '1' (10)end if;end process;3、填寫完成一個8-3線編碼器的VHDL程序(16分)。Library ieee;use ieee.std_logic_1164.all;use
10、 ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity eight_tri is port(b:in std_logic_vector(7 downto 0); (2)en:in std_logic;y:outstd_logic_vector(2 downto 0) (4));end eight_tri;architecture a of eight_tri is (6)signal sel: std_logic_vector(8 downto 0);beginsel<=en & b; (8)y<=
11、“000” when (sel=”100000001”)else“001” when (sel=”100000010”)else (10)“010” when (sel=”100000100”)else“011” when (sel=”100001000”)else“100” when (sel=”100010000”)else (12) “101” when (sel=”100100000”)else“110” when (sel=”101000000”)else (14)“111” when (sel=”110000000”)else (16)“zzz”;end a;4、圖中給出了4位逐位
12、進位全加器,請完成其VHDL程序。(本題16分)library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use IEEE.std_logic_unsigned.all;entity full_add isport (a,b: instd_logic_vector (3 downto 0); (2)carr: inout std_logic_vector (4 downto 0);sum: outstd_logic_vector (3 downto 0);end full_add;architecture ful
13、l_add_arch of full_add iscomponent adder (4)port (a,b,c:instd_logic;carr: inoutstd_logic;sum: out std_logic (6));end component;begincarr(0)<='0'u0:adder port map(a(0),b(0),carr(0),carr(1),sum(0);u1:adder port map(a(1),b(1),carr(1),carr(2),sum(1); (8)(10)u2:adder port map(a(2),b(2),carr(2)
14、,carr(3),sum(2); (12)u3:adder port map(a(3),b(3),carr(3),carr(4),sum(3); (14)(16)end full_add_arch;四、 編程(共50分)1、完成下圖所示的觸發(fā)器。(本題10分)CLRCLKDQQNlibrary IEEE;use IEEE.std_logic_1164.all;entity VposDff is port (CLK, CLR, D: in STD_LOGIC; -2分 Q, QN: out STD_LOGIC ); -4分end VposDff;architecture VposDff_arch
15、 of VposDff isbegin process ( CLK, CLR ) -6分 begin if CLR='1' then Q <= '0' QN <='1' elsif CLK'event and CLK='1' then Q <= D; QN <= not D; -8分 end if; end process; -10分end VposDff_arch; 2、完成以下4位全加器代碼(本題10分)library IEEE;use IEEE.std_logic_1164.all;entit
16、y full_add isport (a,b: instd_logic_vector (3 downto 0);cin: instd_logic;cout: out std_logic;sum: outstd_logic_vector (3 downto 0);end full_add;architecture full_add_arch of full_add iscomponent adderport (a,b,c:instd_logic;carr: outstd_logic;sum: out std_logic);end component;signal c1,c2,c3: std_lo
17、gic; 2分beginu0:adder port map(a(0),b(0),cin,c1,sum(0); 4分u1:adder port map(a(1),b(1),c1,c2,sum(1); 5分u2:adder port map(a(2),b(2),c2,c3,sum(2); 6分u3:adder port map(a(3),b(3),c3,cout,sum(3); 10分end full_add_arch;3、補充完整如下代碼,使之完成4狀態(tài)不斷循環(huán)。(本題10分)ARCHITECTURE arc OF ss IStype states is ( st0,st1,st2,st3 );
18、 2分signal outc: states; 4分BEGINPROCESS(clk) BEGIN IF reset='1' then outc <=st0 ; 6分 elsif clk'event and clk='1' then CASE outc IS WHEN st0 => outc <= st1; 7分 WHEN st1 => outc <= st2; 8分 WHEN st2 => outc <= st3; 9分 WHEN st3 => outc <= st0; 10分 WHEN OTHER
19、S => outc <=st0; END CASE; end if;END PROCESS;END arc; 4、設(shè)計異或門邏輯:(本題20分)如下異或門,填寫右邊的真值表。(此項5分)ABY000011101110其表達式可以表示為:(此項5分) 這一關(guān)系圖示如下:試編寫完整的VHDL代碼實現(xiàn)以上邏輯??梢圆捎萌魏蚊枋龇?。(此項10分)library ieee;use ieee.std_logic_1164.all; 1分entity yihuo1 isport(a,b:in std_logic;y:out std_logic);end yihuo1; 4分architectur
20、e yihuo1_behavior of yihuo1 isbegin 7分process(a,b) y<=a xor b;begin (第2種寫法)if a=b theny<='0'elsey<='1'end if;end process; end yihuo1_behavior; 10分四、 編程(共50分,除特殊聲明,實體可只寫出PORT語句,結(jié)構(gòu)體要寫完整)1、用IF語句編寫一個二選一電路,要求輸入a、b, sel為選擇端,輸出q。(本題10分)Entity sel2 isPort (a,b : in std_logic;sel : i
21、n std_logic;q : out std_logic);End sel2;(3)Architecture a of sel2 isbeginif sel = 0 thenq <= a;(6)elseq <= b;(9)end if;end a;(10)2、編寫一個4位加法計數(shù)器VHDL程序的進程(不必寫整個結(jié)構(gòu)框架),要求復(fù)位信號reset低電平時計數(shù)器清零,變高后,在上升沿開始工作;輸入時鐘信號為clk,輸出為q。(本題10分)Process(reset,clk)(2)beginif reset = 0 thenq <= “0000”;(4)elsif clkeven
22、t and clk = 1 then(6)q <= q + 1;(9)end if;end process;(10)3、填寫完成一個8-3線編碼器的真值表(5分),并寫出其VHDL程序(10分)。8 -3線編碼器真值表enby0y1y21000000000001000000100011000001000101000010000111000100001001001000001011010000001101100000001110xxxxxxxx高阻態(tài)entity eight_tri is port(b:in std_logic_vector(7 downto 0);en:in std_lo
23、gic;y:outstd_logic_vector(2 downto 0);end eight_tri;(3)architecture a of eight_tri is signal sel: std_logic_vector(8 downto 0);(4)beginsel<=en & b;y<= “000” when (sel=”100000001”)else“001” when (sel=”100000010”)else“010” when (sel=”100000100”)else“011” when (sel=”100001000”)else“100” when
24、(sel=”100010000”)else“101” when (sel=”100100000”)else“110” when (sel=”101000000”)else“111” when (sel=”110000000”)else(9)“zzz”;(10)end a;4、根據(jù)已給出的全加器的VHDL程序,試寫出一個4位逐位進位全加器的VHDL程序。(本題15分)library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use IEEE.std_logic_unsigned.all;entity adder i
25、sport (a,b,c:in std_logic;carr: inout std_logic;sum: out std_logic);end adder;architecture adder_arch of adder isbeginsum <= a xor b xor c;carr <= (a and b) or (b and c) or (a and c);end adder_arch;entity full_add isport (a,b: instd_logic_vector (3 downto 0);carr: inout std_logic_vector (4 dow
26、nto 0);sum: outstd_logic_vector (3 downto 0);end full_add;(5)architecture full_add_arch of full_add iscomponent adderport (a,b,c:instd_logic;carr: inoutstd_logic;sum: out std_logic);end component;(10)begincarr(0)<='0'u0:adder port map(a(0),b(0),carr(0),carr(1),sum(0);u1:adder port map(a(1
27、),b(1),carr(1),carr(2),sum(1);u2:adder port map(a(2),b(2),carr(2),carr(3),sum(2);u3:adder port map(a(3),b(3),carr(3),carr(4),sum(3);end full_add_arch;(15)四、 編程(共50分,除特殊聲明,實體可只寫出PORT語句,結(jié)構(gòu)體要寫完整)1、用IF語句編寫一個四選一電路,要求輸入d0d3, s為選擇端,輸出y。(本題10分)entity MUX4 is port(s:in std_logic_vector(1 downto 0);d:in std_l
28、ogic_vector(3 downto 0);y:out std_logic);end MUX4; (3)architecture behave of MUX4 isbeginprocess(s)beginif (s="00") theny<=d(0); (4)elsif (s="01") theny<=d(1); (5)elsif (s="10") theny<=d(2); (6)elsif (s="11") theny<=d(3); (7)elsenull; (9)end if;end
29、 process;end behave; (10)2、編寫一個數(shù)值比較器VHDL程序的進程(不必寫整個結(jié)構(gòu)框架),要求使能信號g低電平時比較器開始工作,輸入信號p = q,輸出equ為0,否則為1。(本題10分)process(p,q)(2)beginif g='0' then(4)if p = q thenequ_tmp <= '0'(6)else equ_tmp <= '1'(8)end if;else equ_tmp <= '1'(10)end if;end process;3、填寫完成一個3-8線譯碼器的
30、真值表(5分),并寫出其VHDL程序(10分)。3-8譯碼器的真值表ena2a1a0y1000000000011001000000101010000001001011000010001100000100001101001000001110010000001111100000000xxx00000000entity tri_eight is port(a:in std_logic_vector (2 downto 0);en:in std_logic;y:outstd_logic_vector (7 downto 0);end tri_eight;(2)architecture a of tri
31、_eight is signal sel:std_logic_vector (3 downto 0);(4)beginsel(0) <= a(0);sel(1) <= a(1);sel(2) <= a(2);sel(3) <= en;(5)with sel selecty <= "00000001" when "1000","00000010" when "1001","00000100" when"1010","00001000" when"1011","00010000" when"1100","00100000" when"1101","01000000" when"1110&qu
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 航空物流智能調(diào)度系統(tǒng)開發(fā)方案
- 行政管理服務(wù)機制試題及答案
- 高端制造業(yè)工程師實習(xí)證明(8篇)
- 智能制造技術(shù)引進與合作協(xié)議
- 行業(yè)協(xié)會會員資格及貢獻證明(8篇)
- 建筑工程經(jīng)濟計算能力測試試題及答案
- 行政管理下市政學(xué)的專業(yè)定位試題及答案
- 2025辦公財產(chǎn)租賃合同范本
- 工程檔案管理規(guī)范試題及答案
- 2025暑假工代理合同協(xié)議書
- 【課程思政教學(xué)案例】《傳熱學(xué)》課程
- 大學(xué)生職業(yè)生涯規(guī)劃與就業(yè)指導(dǎo)第2版(高職)全套教學(xué)課件
- 中國兒童阻塞性睡眠呼吸暫停診斷與治療指南護理課件
- 江西康萊特新森醫(yī)藥原料有限公司年產(chǎn)100 噸注射用薏苡仁油生產(chǎn)項目環(huán)境影響報告
- 醫(yī)學(xué)簡易呼吸器操作及并發(fā)癥和處理措施課件
- 腎性高血壓患者的護理查房課件
- 醫(yī)學(xué)影像數(shù)據(jù)庫建設(shè)與應(yīng)用研究
- 胎兒宮內(nèi)窘迫的護理查房課件
- 海南跨境電商行業(yè)前景分析報告
- 婦科科室全面質(zhì)量與安全管理手冊
- 2023年湖北宜昌市住建局所屬事業(yè)單位人才引進筆試參考題庫(共500題)答案詳解版
評論
0/150
提交評論