资源描述:
《vhdl1602可调数字钟》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、.WORD格式整理..--LCD1602数字钟--Libraryieee;Useieee.std_logic_1164.all;Useieee.std_logic_arith.all;Useieee.std_logic_unsigned.all;EntityclockisPort(rst,clk:instd_logic;rs,en,rst_out,sec_out:outstd_logic;rw:outstd_logic;data_out:outstd_logic_vector(7downto0);RD,WR
2、:INSTD_LOGIC;--读写控制DATA_O,CONT_O:OUTSTD_LOGIC_VECTOR(7DOWNTO0);--数据输出DATA_I,CONT_I:INSTD_LOGIC_VECTOR(7DOWNTO0);--数据和地址输入SCLK:OUTSTD_LOGIC;IO:INOUTSTD_LOGIC;IOB:OUTSTD_LOGIC;k1,k2:INSTD_LOGIC);Endclock;ArchitecturefwmofclockisTYPEstatesIS(hold,func_set,dis
3、_on,mode_set,write_char1,write_char2,write_char3,write_char4,write_char5,write_char6,write_char7,write_char8,write_char9,write_char10,return_home,toggle_e,rst1,rst2,rst3,dis_off,dis_clr);SIGNALstate,n_state:states;SIGNALs0,s1,m0,m1,h0,h1,t:std_logic_vector
4、(3downto0);SIGNALclk_400Hz,clk_10Hz,clk_40Hz:std_logic;SIGNALDATA_TEMP:STD_LOGIC_VECTOR(7DOWNTO0);SIGNALCONT_TEMP:STD_LOGIC_VECTOR(7DOWNTO0);SIGNALSECOND:STD_LOGIC_VECTOR(7DOWNTO0);SIGNALMINUTE:STD_LOGIC_VECTOR(7DOWNTO0);SIGNALHOUR:STD_LOGIC_VECTOR(7DOWNTO
5、0);SIGNALDAY:STD_LOGIC_VECTOR(7DOWNTO0);CONSTANTPROCECT:STD_LOGIC_VECTOR:="10001110";--保护位CONSTANTSECOND_WRITE:STD_LOGIC_VECTOR:="10000000";CONSTANTSECOND_READ:STD_LOGIC_VECTOR:="10000001";CONSTANTMINUTE_WRITE:STD_LOGIC_VECTOR:="10000010";CONSTANTMINUTE_RE
6、AD:STD_LOGIC_VECTOR:="10000011";CONSTANTHOUR_WRITE:STD_LOGIC_VECTOR:="10000100";CONSTANTHOUR_READ:STD_LOGIC_VECTOR:="10000101";..专业知识分享...WORD格式整理..CONSTANTDAY_WRITE:STD_LOGIC_VECTOR:="10000110";CONSTANTDAY_READ:STD_LOGIC_VECTOR:="10000111";--CONSTANTMONTH
7、_WRITE:STD_LOGIC_VECTOR:="10001000";--CONSTANTMONTH_READ:STD_LOGIC_VECTOR:="10001001";--CONSTANTYEAR_WRITE:STD_LOGIC_VECTOR:="10001100";--CONSTANTYEAR_READ:STD_LOGIC_VECTOR:="10001101";Beginrst_out<=NOTrst;sec_out<=s0(0);Process(clk,rst)--50MHz分频到400Hzvari
8、ablecnt1:integerrange0to62500;beginifrst='0'thencnt1:=0;clk_400Hz<='0';elsifclk'EVENTandclk='1'thenifcnt1<62500thencnt1:=cnt1+1;elsecnt1:=0;clk_400HZ<=notclk_400Hz;endif;endif;endprocess;process(clk_400HZ,rst