您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > 8421码十进制计数器
8421码十进制计数器:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYGKY07P10ISPORT(clk,reset:INSTD_LOGIC;q:OUTSTD_LOGIC_VECTOR(3DOWNTO0));ENDGKY07P10;ARCHITECTUREstrucOFGKY07P10ISSIGNALq_temp:STD_LOGIC_VECTOR(3DOWNTO0);BEGINPROCESS(clk)BEGINIF(clk'EVENTANDclk='1')THENIFreset='1'THENq_temp=0000;ELSIFq_temp=1001THENq_temp=0000;ELSEq_temp=q_temp+1;ENDIF;ENDIF;ENDPROCESS;q=q_temp;ENDstruc;从状态‘0000’到状态‘1001’,然后再跳回‘0000’,异步复位要立即复位。分频器:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYGKY07P13ISPORT(clk,clear:INSTD_LOGIC;clk_out:OUTSTD_LOGIC);ENDGKY07P13;ARCHITECTUREstrucOFGKY07P13ISSIGNALtemp:INTEGERRANGE0TO11;BEGINp1:PROCESS(clear,clk)BEGINIFclear='0'THENtemp=0;ELSIFclk'EVENTANDclk='1'THENIFtemp=11THENtemp=0;ELSEtemp=temp+1;ENDIF;ENDIF;ENDPROCESSp1;p2:PROCESS(temp)BEGINIFtemp6THENclk_out='0';ELSEclk_out='1';ENDIF;ENDPROCESSp2;ENDstruc;很重要的一个器件,但是设计难度并不很高,首先是模为12的计数,然后是占空比50%。LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYLEDISPORT(a:INSTD_LOGIC_VECTOR(3DOWNTO0);b:OUTSTD_LOGIC_VECTOR(6DOWNTO0));ENDLED;ARCHITECTURELEDarchOFLEDISBEGINPROCESS(a)BEGINCASEaISWHEN0000=b=1111110;--0WHEN0001=b=0110000;--1WHEN0010=b=1101101;--2WHEN0011=b=1111001;--3WHEN0100=b=0110011;--4WHEN0101=b=1011011;--5WHEN0110=b=1011111;--6WHEN0111=b=1110000;--7WHEN1000=b=1111111;--8WHEN1001=b=1111011;--9WHENOTHERS=b=0000000;ENDCASE;ENDPROCESS;END;
本文标题:8421码十进制计数器
链接地址:https://www.777doc.com/doc-1954565 .html