欢迎来到天天文库
浏览记录
ID:48386222
大小:53.00 KB
页数:11页
时间:2019-08-04
《vhdl语言编程实例.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实现各种逻辑功能:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYlouji1aISPORT(S:INSTD_LOGIC_VECTOR(2DOWNTO0);C:INSTD_LOGIC;A:INSTD_LOGIC_VECTOR(4DOWNTO0);B:INSTD_LOGIC_VECTOR(4DOWNTO0);F:OUTSTD_LOGIC_VECTOR(4DOWNTO0));ENDENTITYlouji1a;ARCHITECTUREONEOFlouj
2、i1aISBEGINF<=AWHENS="000"ELSEA-BWHENS="001"ELSEA-1WHEN(S="010"ANDC='0')ELSEA+1WHEN(S="011"ANDC='0')ELSEAANDBWHENS="100"ELSEAORBWHENS="101"ELSEAXORBWHENS="110"ELSENOTAWHENS="111"ELSENULL;ENDARCHITECTUREONE;38译码器:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYyimaqi1aISPORT(A:INST
3、D_LOGIC_VECTOR(3DOWNTO0);B:OUTSTD_LOGIC_VECTOR(6DOWNTO0));ENDENTITYyimaqi1a;ARCHITECTUREoneOFyimaqi1aIS--SIGNALabc:STD_LOGIC_VECTOR(3DOWNTO0);--SIGNALdef:STD_LOGIC_VECTOR(6DOWNTO0);BEGIN--abc<=A3&A2&A1&A0;--def<=g&f&e&d&c&b&a;PROCESS(A)BEGINcaseAISWHEN"0000"=>B<="0111111";WHEN
4、"0001"=>B<="0000110";WHEN"0010"=>B<="1011011";WHEN"0011"=>B<="1001111";WHEN"0100"=>B<="1100110";WHEN"0101"=>B<="1101101";WHEN"0110"=>B<="1111101";WHEN"0111"=>B<="0000111";WHEN"1000"=>B<="1111111";WHEN"1001"=>B<="1101111";WHEN"1010"=>B<="1110111";WHEN"1011"=>B<="1111100";WHEN"1
5、100"=>B<="0111001";WHEN"1101"=>B<="1011110";WHEN"1110"=>B<="1111001";WHEN"1111"=>B<="1110001";WHENOTHERS=>NULL;ENDCASE;ENDPROCESS;ENDARCHITECTUREONE;十进制计数器:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYjishuqi1aISPORT(CLK,EN,CTRL,CLR:INSTD_LOGIC;Q
6、:OUTSTD_LOGIC_VECTOR(3DOWNTO0);CO:OUTSTD_LOGIC);ENDENTITYjishuqi1a;ARCHITECTUREBHVOFjishuqi1aISSIGNALQQ:STD_LOGIC_VECTOR(3DOWNTO0);BEGINPROCESS(CLK,EN,CTRL,CLR)--VARIABLEQQ:STD_LOGIC_VECTOR(3DOWNTO0);BEGINIFCLR='0'THENQQ<="0000";ELSIFCTRL='0'THENQQ<="0000";ELSIFCLK'EVENTANDCLK
7、='1'THENIFEN='1'THENIFQQ<9THENQQ<=QQ+1;ELSEQQ<="0000";ENDIF;ENDIF;ENDIF;IFQQ="0000"THENCO<='1';ELSECO<='0';ENDIF;ENDPROCESS;Q<=QQ;ENDARCHITECTUREBHV;实现六十进制计数器:1.实现任何计数器:2.libraryieee;useieee.std_logic_1164.all;--useieee.std_logic_unsigned.all;entityncountisgeneric(n:integer:=6
8、);port(clk:instd_logic;clr:instd_logic;--updown:instd_logic;e
此文档下载收益归作者所有