数字钟vhdl代码

数字钟vhdl代码

ID:39578138

大小:53.00 KB

页数:9页

时间:2019-07-06

数字钟vhdl代码_第1页
数字钟vhdl代码_第2页
数字钟vhdl代码_第3页
数字钟vhdl代码_第4页
数字钟vhdl代码_第5页
资源描述:

《数字钟vhdl代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;  entity shuzizhong is port(clk : in std_logic;   ‐‐‐时钟信号      choose,set,s1,s2:in std_logic; ‐‐‐‐12/24时制选择,设置,时设置,分设置      am,pm,spk:out std_logic;  ‐‐‐‐上午,下午,报时信号      b:out std_logic_vector(6 downto 0); 

2、‐‐‐‐七段数码管      cat:out std_logic_vector(5 downto 0) ‐‐‐数码管选通控制信号      ); end shuzizhong; architecture a of shuzizhong is signal hou1 : integer range 0 to 23;  ‐‐‐24时制小时信号 signal hou2 : integer range 0 to 11;  ‐‐‐12时制小时信号 signal min : integer range 0 to 59;   ‐‐‐分信号 signal sec : in

3、teger range 0 to 59;   ‐‐‐秒信号 signal temp: integer range 0 to 19; signal clk0:std_logic;           ‐‐‐‐‐计时时钟信号 signal tmp:integer range 0 to 999999; signal a:std_logic_vector(1 downto 0); type str is array (0 to 5) of integer range 0 to 9;   ‐‐‐定义整型数组 signal timeout : str; signal 

4、count : integer range 0 to 5; begin     p1:process(clk)            ‐‐‐‐ 分频模块        begin          if clk'event and  clk='1' then             if tmp= 999999 then    ‐‐‐1M分频  ;  tmp<=0;             else                 tmp<=tmp+1;             end if;             if tmp<500000 then 

5、               clk0<='0';             else                 clk0<='1';             end if;           end if;        end process p1;     p2: process(clk0,choose,set,s1,s2)           begin                  if clk0'event and clk0='1' then             if set='0' then          ‐‐‐‐计时模块 

6、               sec<=sec+1;        ‐‐‐‐秒计时 if sec=59 then                     sec<=0;      ‐‐‐‐‐秒进位                     min<=min+1;  ‐‐‐‐分计时                      if min=59 then                         min<=0;                                                hou1<=hou1+1;  ‐‐‐‐24小时进制小

7、时位计时                           if hou1=23 then                              hou1<=0;                           end if;                         hou2<=hou2+1;  ‐‐‐‐12小时进制小时位计时                           if hou2=11 then                              hou2<=0;                           e

8、nd if;                      end i

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。