电子时钟程序代码.docVIP

  • 36
  • 0
  • 约2.91千字
  • 约 3页
  • 2020-07-26 发布于河北
  • 举报
(一) 计时模块 1. 秒计数是由一个六十进制的计数器构成,生成元器件如下 Clk:驱动秒计时器的时钟信号 Clr:校准时间时清零的输入端 En:使能端 Sec0[3..0]sec1[3..0]:秒的高位显示,低位显示 Co:进位输出端,作为分的clk输入 代码如下: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity second is port (clk,clr,en:in std_logic; sec0,sec1:out std_logic_vector(3 downto 0); co:outstd_logic); end second; architecture sec of second is SIGNAL cnt1,cnt0:std_logic_vector(3 downto0); begin process(clk) begin if(clr=0)then cnt0=0000; cnt1=0000; elsif(clkeventand clk=1)then if(en=1)then ifcnt1=0101 and cnt0=1000 then co=1; cnt0=1001; elsifcnt01001 then cnt0=(cnt0+1); else cnt0=0000; ifcnt10101then cnt1=cnt1+1; else cnt1=0000; co=0; endif; endif; endif; endif; sec1=cnt1; sec0=cnt0; endprocess; end sec; 2.分计数是由六十进制的计数器构成,生成元器件如下 Clk:设置分输入和秒进位的或输入 En:使能输入 Min1[3..0] min0[3..0]:分的高位显示,低位显示 Co:向时的进位输出 代码如下: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity minute is port (clk,en:in std_logic; min1,min0:out std_logic_vector(3 downto 0); co:outstd_logic); end minute; architecture min of minute is SIGNAL cnt1,cnt0:std_logic_vector(3 downto0); begin process(clk) begin if(clkeventand clk=1)then ifen=1 then ifcnt1=0101 and cnt0=1001 then co=1; cnt0=0000; cnt1=0000; elsifcnt01001 then cnt0=(cnt0+1); else

文档评论(0)

1亿VIP精品文档

相关文档