VHDL程序设计题(43页).doc





《VHDL程序设计题(43页).doc》由会员分享,可在线阅读,更多相关《VHDL程序设计题(43页).doc(45页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-VHDL程序设计题四、 编程题(共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; end CONNECT ; (10
2、)2、编写一个2输入与门的VHDL程序,请写出库、程序包、实体、构造体相关语句,将端口定义为标准逻辑型数据结构(本题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) END nand2_1;3、根据下表填写完成一个3-
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 indata y y y y y y y y y = XXX
4、XXXXX; END CASE; ELSE y = 11111111;(14) END IF; END PROCESS;(16)END rtl; 4、三态门电原理图如右图所示,真值表如左图所示,请完成其VHDL程序构造体部分。(本题14分)LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL;ENTITY tri_gate ISPORT(din,en:IN STD_LOGIC; dout : OUT STD_LOGIC);END tri_gate ;ARCHITECTURE zas OF tri_gate ISBEGIN PROCESS (din,en) BEGI
5、NIF (en=1) THEN dout = din;ELSE dout = Z; END IF; END PROCESS ;END zas ;四、 编程题(共50分)1、根据一下四选一程序的结构体部分,完成实体程序部分(本题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 std_logic (8); end MUX4; architecture behave of MUX4 isbeginprocess(s)beginif
6、(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、编写一个数值比较器VHDL程序的进程(不必写整个结构框架),要求使能信号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;e
7、lse equ = 1; (10)end if;end process;3、填写完成一个8-3线编码器的VHDL程序(16分)。Library ieee;use ieee.std_logic_1164.all;use 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;ar
8、chitecture a of eight_tri is (6)signal sel: std_logic_vector(8 downto 0);beginsel=en & b; (8)y= “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“
9、110” when (sel=”101000000”)else (14)“111” when (sel=”110000000”)else (16)“zzz”;end a;4、图中给出了4位逐位进位全加器,请完成其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 s
10、td_logic_vector (4 downto 0);sum: outstd_logic_vector (3 downto 0);end full_add;architecture full_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 po
11、rt map(a(1),b(1),carr(1),carr(2),sum(1); (8)(10)u2:adder port map(a(2),b(2),carr(2),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、完成下图所示的触发器。(本题10分)CLRCLKDQQNlibrary IEEE;use IEEE.std_logic_1164.all;entity VposDff is port (CLK, CLR, D:
12、 in STD_LOGIC; -2分 Q, QN: out STD_LOGIC ); -4分end VposDff;architecture VposDff_arch of VposDff isbegin process ( CLK, CLR ) -6分 begin if CLR=1 then Q = 0; QN =1; elsif CLKevent 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.
13、std_logic_1164.all;entity 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
14、;signal c1,c2,c3: std_logic; 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状态不断循环。(本题10分)ARCHITECTURE arc OF ss IStype states
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VHDL 程序设计 43

限制150内