VHDL程序设计题

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

VHDL程序设计题四、编程题(共50分)1、请补全以下二选一VHDL程序(本题10分)Entitymuxisport(d0,d1,sel:inbit;q:outBIT);(2)endmux;architectureconnectofMUXis(4)signaltmp1,TMP2,tmp3:bit;(6)begincale:blockbegintmp1=d0andsel;tmp2=d1and(notsel)tmp3=tmp1andtmp2;q=tmp3;(8)endblockcale;endCONNECT;(10)2、编写一个2输入与门的VHDL程序,请写出库、程序包、实体、构造体相关语句,将端口定义为标准逻辑型数据结构(本题10分)LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;(2)ENTITYnand2ISPORT(a,b:INSTD_LOGIC;(4)&aby1y:OUTSTD_LOGIC);(6)ENDnand2;ARCHITECTUREnand2_1OFnand2IS(8)BEGINy=aNANDb;--与y=NOT(aANDb);等价(10)ENDnand2_1;3、根据下表填写完成一个3-8线译码器的VHDL程序(16分)。LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYdecoder_3_to_8ISPORT(a,b,c,g1,g2a,g2b:INSTD_LOGIC;y:OUTSTD_LOGIC_VECTOR(7DOWNTO0));(2)ENDdecoder_3_to_8;ARCHITECTURErtlOFdecoder_3_to_8ISSIGNALindata:STD_LOGIC_VECTOR(2DOWNTO0);(4)BEGINindata=c&b&a;(6)PROCESS(indata,g1,g2a,g2b)BEGINIF(g1='1'ANDg2a='0'ANDg2b='0')THEN(8)CASEindataISWHEN000=y=11111110;WHEN001=y=11111101;WHEN010=y=11111011;(10)WHEN011=y=11110111;WHEN100=y=11101111;WHEN101=y=11011111;WHEN110=y=10111111;(12)WHEN111=y=01111111;WHENOTHERS=y=XXXXXXXX;ENDCASE;ELSE2y=11111111;(14)ENDIF;ENDPROCESS;(16)ENDrtl;4、三态门电原理图如右图所示,真值表如左图所示,请完成其VHDL程序构造体部分。(本题14分)LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYtri_gateISPORT(din,en:INSTD_LOGIC;3dout:OUTSTD_LOGIC);ENDtri_gate;ARCHITECTUREzasOFtri_gateISBEGINPROCESS(din,en)BEGINIF(en=‘1')THENdout=din;ELSEdout=‘Z’;ENDIF;ENDPROCESS;ENDzas;四、编程题(共50分)1、根据一下四选一程序的结构体部分,完成实体程序部分(本题8分)entityMUX4isport((2)s:instd_logic_vector(1downto0);(4)d:instd_logic_vector(3downto0);(6)y:outstd_logic(8));endMUX4;architecturebehaveofMUX4isbeginprocess(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);else4null;endif;endprocess;endbehave;2、编写一个数值比较器VHDL程序的进程(不必写整个结构框架),要求使能信号g低电平时比较器开始工作,输入信号p=q,输出equ为‘0’,否则为‘1’。(本题10分)process(p,q)(2)beginifg='0'then(4)ifp=qthenequ='0';(6)elseequ='1';(8)endif;elseequ='1';(10)endif;endprocess;3、填写完成一个8-3线编码器的VHDL程序(16分)。Libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entityeight_triisport(b:instd_logic_vector(7downto0);(2)en:instd_logic;y:outstd_logic_vector(2downto0)(4));endeight_tri;5architectureaofeight_triis(6)signalsel:std_logic_vector(8downto0);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“110”when(sel=”101000000”)else(14)“111”when(sel=”110000000”)else(16)“zzz”;enda;4、图中给出了4位逐位进位全加器,请完成其VHDL程序。(本题16分)libraryIEEE;useIEEE.std_logic_1164.all;useIEEE.std_logic_arith.all;useIEEE.std_logic_unsigned.all;entityfull_addisport(a,b:instd_logic_vector(3downto0);(2)carr:inoutstd_logic_vector(4downto0);sum:outstd_logic_vector(3downto0)6);endfull_add;architecturefull_add_archoffull_addiscomponentadder(4)port(a,b,c:instd_logic;carr:inoutstd_logic;sum:outstd_logic(6));endcomponent;begincarr(0)='0';u0:adderportmap(a(0),b(0),carr(0),carr(1),sum(0));u1:adderportmap(a(1),b(1),carr(1),carr(2),sum(1));(8)(10)u2:adderportmap(a(2),b(2),carr(2),carr(3),sum(2));(12)u3:adderportmap(a(3),b(3),carr(3),carr(4),sum(3));(14)(16)endfull_add_arch;四、编程(共50分)1、完成下图所示的触发器。(本题10分)libraryIEEE;useIEEE.std_logic_1164.all;entityVposDffisport(CLK,CLR,D:inSTD_LOGIC;----------2分CLRCLKDQQN7Q,QN:outSTD_LOGIC);----------4分endVposDff;architectureVposDff_archofVposDffisbeginprocess(CLK,CLR)----------6分beginifCLR='1'thenQ='0';QN='1';elsifCLK'eventandCLK='1'thenQ=D;QN=notD;----------8分endif;endprocess;----------10分endVposDff_arch;2、完成以下4位全加器代码(本题10分)libraryIEEE;useIEEE.std_logic_1164.all;entityfull_addisport(a,b:instd_logic_vector(3downto0);cin:instd_logic;cout:outstd_logic;sum:outstd_logic_vector(3downto0));endfull_add;architecturefull_add_archoffull_addiscomponentadderport(a,b,c:instd_logic;carr:outstd_logic;sum:outstd_logic);endcomponent;signalc1,c2,c3:std_logic;2分8beginu0:adderportmap(a(0),b(0),cin,c1,sum(0));4分u1:adderportmap(a(1),b(1),c1,c2,sum(1));5分u2:adderportmap(a(2),b(2),c2,c3,sum(2));6分u3:adderportmap(a(3),b(3),c3,cout,sum(3));10分endfull_add_arch;3、补充完整如下代码,使之完成4状态不断循环。(本题10分)ARCHITECTUREarcOFssIStypestatesis(st0,st1,st2,st3);2分signaloutc:states;4分BEGINPROCESS(clk)BEGINIFreset='1'thenoutc=st0;6分elsifclk'eventandclk='1'thenCASEoutcISWHENst0=outc=st1;7分WHENst1=outc=st2;8分WHENst2=outc=st3;9分WHENst3=outc=st0;10分WHENOTHERS=outc=st0;ENDCASE;endif;ENDPROCESS;ENDarc;4、设计异或门逻辑:(本题20分)如下异或门,填写右边的真值表。(此项5分)9其表达式可以表示为:(此项5分)这一关系图示如下:试编写完整的VHDL代码实现以上逻辑。可以采用任何描述法。(此项10分)libraryieee;useieee.std_logic_1164.all;1分entityyihuo1isport(a,b:instd_logic;y:outstd_logic);endyihuo1;4分architectureyihuo1_behaviorofyihuo1isbegin7分process(a,b)y=axorb;begin(第2种写法)ifa=btheny='0';elsey='1';ABY000011101110&&+ababy10endif;endprocess;endyihuo1_behavior;10分四、编程(共50分,除特殊声明,实体可只写出PORT语句,结构体要写完整)1、用IF语句编写一个二选一电路,要求输入a、b,sel为选择端,输出q。(本题10分)Entitysel2isPort(a,b:instd_logic;sel:instd_logic;q:outstd_logic);Endsel2;(3)Architectureaofsel2isbeginifsel=‘0’th

1 / 18
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功