資源描述:
《數(shù)字鐘程序及波形仿真圖.doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、部件一:60進制程序LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYCLOCK60ISPORT(CLK:INSTD_LOGIC;---時鐘信號NRESET:INSTD_LOGIC;---復位端LOAD:INSTD_LOGIC;---置數(shù)端D:INSTD_LOGIC_VECTOR(7DOWNTO0);---輸入端CI:INSTD_LOGIC;---始能端CO:OUTSTD_LOGIC;---進位脈沖QH:BUFFERSTD_LOGIC_V
2、ECTOR(3DOWNTO0);QL:BUFFERSTD_LOGIC_VECTOR(3DOWNTO0));ENDCLOCK60;ARCHITECTUREARTCLOCK60OFCLOCK60ISBEGINCO<='1'WHEN(QH="0101"ANDQL="1001"ANDCI='1')ELSE'0';----進位輸出PROCESS(CLK,NRESET)BEGINIF(NRESET='0')THEN-----異步復位QH<="0000";QL<="0000";ELSIF(CLK'EVENTANDCLK='1')THEN------同步
3、置數(shù)IF(LOAD='1')THENQH<=D(7DOWNTO4);QL<=D(3DOWNTO0);ELSIF(CI='1')THENIF(QL=9)THENQL<="0000";IF(QH=5)THENQH<="0000";ELSEQH<=QH+1;ENDIF;ELSEQL<=QL+1;ENDIF;ENDIF;ENDIF;ENDPROCESS;ENDARTCLOCK60;60進制波形圖如下:部件二:24進制程序LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNE
4、D.ALL;ENTITYCLOCK24ISPORT(CLK:INSTD_LOGIC;---時鐘信號NRESET:INSTD_LOGIC;---復位端LOAD:INSTD_LOGIC;---置數(shù)端D:INSTD_LOGIC_VECTOR(7DOWNTO0);---輸入端CI:INSTD_LOGIC;---始能端CO:OUTSTD_LOGIC;---進位脈沖QH:BUFFERSTD_LOGIC_VECTOR(3DOWNTO0);QL:BUFFERSTD_LOGIC_VECTOR(3DOWNTO0));ENDCLOCK24;ARCHITECTU
5、REARTCLOCK24OFCLOCK24ISBEGINCO<='1'WHEN(QH="0101"ANDQL="1001"ANDCI='1')ELSE'0';----進位輸出PROCESS(CLK,NRESET)BEGINIF(NRESET='0')THEN-----異步復位QH<="0000";QL<="0000";ELSIF(CLK'EVENTANDCLK='1')THEN------同步置數(shù)IF(LOAD='1')THENQH<=D(7DOWNTO4);QL<=D(3DOWNTO0);ELSIF(CI='1')THENIF(QL=9
6、or(QH=2ANDQL=3))THENQL<="0000";IF(QH=2)THENQH<="0000";ELSEQH<=QH+1;ENDIF;ELSEQL<=QL+1;ENDIF;ENDIF;ENDIF;ENDPROCESS;ENDARTCLOCK24;24進制的波形圖如下:數(shù)字鐘的全部程序如下:LIBRARYIEEE;---秒信號USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_UNSIGNED.ALL;ENTITYCLOCK60sISPORT(CLK:INSTD_LOGIC;---時鐘信號N
7、RESET:INSTD_LOGIC;---復位端LOAD:INSTD_LOGIC;---置數(shù)端D:INSTD_LOGIC_VECTOR(7DOWNTO0);---輸入端CI:INSTD_LOGIC;---始能端CO:OUTSTD_LOGIC;---進位脈沖QH:BUFFERSTD_LOGIC_VECTOR(3DOWNTO0);QL:BUFFERSTD_LOGIC_VECTOR(3DOWNTO0));ENDCLOCK60s;ARCHITECTUREARTCLOCK60sOFCLOCK60sISBEGINCO<='1'WHEN(QH="010
8、1"ANDQL="1001"ANDCI='1')ELSE'0';--進位輸出PROCESS(CLK,NRESET)BEGINIF(NRESET='0')THEN---異步復位QH<="0000