VHDL程序设计题_第1页
VHDL程序设计题_第2页
VHDL程序设计题_第3页
免费预览已结束,剩余15页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

;.;.四、编程题(共50 分)vhdl程序设计题1、请补全以下二选一vhdl程序(本题10 分) entity mux isport(d0,d1,sel:in bit;q:outbit);(2)end mux;architecture connect ofmuxis(4) signal tmp1,tmp2,tmp3:bit;(6)begincale: blockbegintmp1=d0 and sel; tmp2=d1 and (not sel)tmp3= tmp1 and tmp2;q=tmp3;(8)end block cale;endconnect;(10)2、编写一个2 输入与门的vhdl程序,请写出库、程序包、实体、构造体相关语句,将端口定义为标准逻辑型数据结构(本题10 分)a&y blibrary ieee;use ieee.std_logic_1164.all;( 2)entity nand2 isport (a, b:instd_logic;( 4)y:out std_logic);( 6)end nand2;architecture nand2_1 of nand2 is( 8) beginy = a nand b;- 与 y =not( a and b);等价( 10) end nand2_1;3、根据下表填写完成一个3-8 线译码器的vhdl程序( 16 分)。library ieee;use ieee.std_logic_1164.all;entity decoder_3_to_8 isport (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 issignal indata:std_logic_vector (2 downto 0);( 4) beginindata y y y y y y y y y = xxxxxxxx; end case;elsey= 11111111;(14)end if;end process;(16)end rtl;4、三态门电原理图如右图所示,真值表如左图所示,请完成其vhdl程序构造体部分。(本题 14 分)library ieee;use ieee.std_logic_1164.all;entity tri_gate is port(din,en:in std_logic;s:in std_logic_vector(1 downto 0);(4)d:in std_logic_vector(3 downto 0);(6)y:);out std_logic(8)dout : out std_logic);end tri_gate ;architecture zas of tri_gate is beginprocess (din,en)beginif (en= 1)else end if;thendout = din;dout = z;end process ;end zas ;四、编程题(共50 分)1、根据一下四选一程序的结构体部分,完成实体程序部分(本题entity mux4 is8 分)port(2)end mux4;architecture behave of mux4 is beginprocess(s)beginif (s=00) theny=d(0);elsif (s=01) then y=d(1);elsif (s=10) then y=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)elseequ = 1;(8)elseend if;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();end eight_tri;b:in std_logic_vector(7 downto 0);( 2)en:in std_logic;y:outstd_logic_vector(2 downto 0)( 4)architecture 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 (se1l=0001”0000” )else( 12) “ 101 ” wh(esnel=” 100100000 ” )else“110” when (sel=” 101000000 ” )else( 14)“ 111 ” when (se1l=1000”0000” )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 is port (a,b:instd_logic_vector (3 downto 0);( 2)carr:sum:inoutoutstd_logic_vector (4 downto 0);std_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:outstd_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),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 分)clrqclkdqnlibrary ieee;use ieee.std_logic_1164.all;entityvposdffisport (clk, clr, d: instd_logic;-2 分q, qn: outstd_logic);-4分end vposdff;architecture vposdff_arch of vposdff is beginprocess (clk, clr)-6分beginif clr=1 thenq = 0;qn =1;elsif clkevent and clk=1 thenq = d; qn outc =st0; end case;beginu0:adder port map(a(0),b(0),cin,c1,sum(0);u1:adder port map(a(1),b(1),c1,c2,sum(1);u2:adder port map(a(2),b(2),c2,c3,sum(2);u3:adder port map(a(3),b(3),c3,cout,sum(3); end full_add_arch;4 分5 分6 分10 分process(clk) beginif reset=1 thenoutc outc outc outc outc = st0;6 分7 分8 分9 分10 分4、设计异或门逻辑: (本题 20 分)如下异或门,填写右边的真值表。(此项 5 分);.aby000011101110其表达式可以表示为: (此项 5 分)a这一关系图示如下:ab&yb&试编写完整的vhdl代码实现以上逻辑。可以采用任何描述法。(此项 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 分architecture yihuo1_behavior of yihuo1 isbegin7 分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 语句,结构体要写完整)1、用 if 语句编写一个二选一电路,要求输入a、b, sel 为选择端,输出q。(本题 10 分)entity sel2 is port (a,b : in std_logic; sel : in std_logic; q : out std_logic);end sel2;(3)architecture a of sel2 is beginif sel = 0thenq = a;(6)elseq = b;(9)end if;end a;(10)2、编写一个4 位加法计数器vhdl程序的进程(不必写整个结构框架),要求复位信号reset 低电平时计数器清零,变高后,在上升沿开始工作;输入时钟信号为clk,输出为q。(本题 10 分)process(reset,clk)(2)begin;.enby0y1y21000000000001000000100011000001000101000010000111000100001001001000001011010000001101100000001110xxxxxxxx高阻态if reset = 0thenq = “0000”;elsif clk event and clk = 1then q = q + 1;end if;end process;(4)(6)(9)(10)3、填写完成一个8-3 线编码器的真值表(5 分),并写出其vhdl 程序( 10 分)。8 -3 线编码器真值表entity eight_tri is port(b:in std_logic_vector(7 downto 0); en:in std_logic;y:outstd_logic_vector(2 downto 0);end eight_tri;(3)architecture a of eight_tri issignal 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 (sel=” 100010000” )else“ 101 ”when (sel=” 100100000” )else“ 110 ”when (sel=” 101000000” )else“ 111 ”when (sel=” 110000000” )else(9)“zzz”;(10)end a;4、根据已给出的全加器的vhdl程序,试写出一个4 位逐位进位全加器的vhdl程序。(本题 15 分) library ieee;use ieee.std_logic_1164.all; use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all; entityadderisport ();endadder;a,b,c:instd_logic; carr:inoutstd_logic;sum:outstd_logicarchitecture adder_arch of adder is beginsum = a xor b xor c;carr = (a and b) or (b and c) or (a and c); endadder_arch;entity full_add isport (a,b:instd_logic_vector (3 downto 0);carr:inoutstd_logic_vector (4 downto 0);sum:outstd_logic_vector (3 downto 0);end full_add;(5)architecture full_add_arch of full_add is component adderport (a,b,c:instd_logic; carr:inoutstd_logic; sum:outstd_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),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 语句,结构体要写完整)1、用 if 语句编写一个四选一电路,要求输入d0d3, s 为选择端,输出y。(本题 10 分)entity mux4 is port(s:in std_logic_vector(1 downto 0);d:in std_logic_vector(3 downto 0); y:out std_logic);end mux4;(3)architecture behave of mux4 is beginprocess(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 process;end behave;(10)2、编写一个数值比较器vhdl 程序的进程 (不必写整个结构框架),要求使能信号g 低电平时比较器开始工作,输入信号p = q,输出 equ 为 0,否则为 1。(本题 10 分)process(p,q)(2)beginif g=0 then(4)if p = q thenequ_tmp = 0;(6)elseequ_tmp = 1;(8)elseend if;equ_tmp = 1;(10)end if; end process;3、填写完成一个3-8 线译码器的真值表(5 分),并写出其vhdl 程序( 10 分)。3-8 译码器的真值表ena2a1a0y1000000000011001000000101010000001001011000010001100000100001101001000001110010000001111100000000xxx00000000entitytri_eightis 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_eight issignalsel: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 when1010,00001000 when1

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论