数字时钟设计.doc_第1页
数字时钟设计.doc_第2页
数字时钟设计.doc_第3页
数字时钟设计.doc_第4页
数字时钟设计.doc_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity clock isport(clk:in std_logic;-时钟脉冲clk1:in std_logic;-数码管选通时钟脉冲dout:out std_logic_vector(6 downto 0);-数码管七段码输出selout:out std_logic_vector(6 downto 0);-数码管选通输出start:in std_logic;-开始stop:in std_logic);-停止end clock;architecture one of clock issignal sel:std_logic_vector(6 downto 0);-6进制(数码管选通输入)signal hou1:std_logic_vector(3 downto 0);-小时十位signal hou2:std_logic_vector(3 downto 0);-小时个位signal min1:std_logic_vector(3 downto 0);-分钟十位signal min2:std_logic_vector(3 downto 0);-分钟个位signal sec1:std_logic_vector(3 downto 0);-秒十位signal sec2:std_logic_vector(3 downto 0);-秒个位signal h1:std_logic_vector(3 downto 0); -输出小时十位signal h2:std_logic_vector(3 downto 0); -输出小时个位signal m1:std_logic_vector(3 downto 0); -输出分钟十位signal m2:std_logic_vector(3 downto 0); -输出分钟个位signal s1:std_logic_vector(3 downto 0); -输出秒十位signal s2:std_logic_vector(3 downto 0); -输出秒个位signal sec3:std_logic_vector(3 downto 0); -1/10秒signal s3:std_logic_vector(3 downto 0); -输出1/10秒-begin-6进制(数码管选通)choice:process(clk1)beginif clk1event and clk1=1 then if sel=0000101 or stop=1 then sel=0000000; elsif start=1 then sel=sel+1; end if;end if;end process choice;selout=sel;-小时十位h110:process(clk,hou2,min1,min2,sec1,sec2)beginif clkevent and clk=1 then if (hou1=0010 and hou2=0011)and(min1=0101 and min2=1001)or stop=1 then hou1=0000; elsif (hou1=0010and hou2=0011 and stop=1) then hou1=0000;elsif (hou2=1001and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001)and start=1)or hou2=1001)then hou1=hou1+1; end if;end if;h1=hou1;end process h110;-小时个位h220:process(clk,min1,min2,sec1,sec2,hou1)beginif clkevent and clk=1 then if (hou1=0010 and hou2=0011)and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001)or stop=1 then hou2=0000; elsif (hou2=1001and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001)or stop=1 then hou2=0000; elsif (hou2=1001 or (hou1=0010and hou2=0011 )or stop=1 then hou2=0000; elsif (min1=0101 and min2=1001) and (sec1=0101 and sec2=1001)and start=1 then hou2=hou2+1; end if;end if;h2=hou2;end process h220;-分钟十位m110:process(clk,min2,sec1,sec2)beginif clkevent and clk=1 then if (min1=0101 and min2=1001) and (sec1=0101 and sec2=1001)or stop=1 then min1=0000; elsif (min1=0101and min2=1001)or stop=1 then min1=0000; elsif (min2=1001and (sec1=0101 and sec2=1001) or min2=1001)and start=1 then min1=min1+1; end if;end if;m1=min1;end process m110;-分钟个位m220:process(clk,sec1,sec2)beginif clkevent and clk=1 then if (min2=1001and (sec1=0101 and sec2=1001)or stop=1then min2=0000; elsif (min2=1001or stop=1)then min2=0000; elsif (sec1=0101 and sec2=1001and start=1)then min2=min2+1; end if;end if;m2=min2;end process m220;-秒十位s110:process(clk,sec1,sec2)beginif (clkevent and clk=1) then if (sec1=0101 and sec2=1001)or stop=1 then sec1=0000; elsif (sec2=1001and start=1)then sec1=sec1+1; end if;end if;s1=sec1;end process s110;-秒个位s220:process(clk,sec2)beginif (clkevent and clk=1) then if (sec2=1001 or stop=1)then sec2=0000; elsif start=1 then sec2=sec2+1; end if; end if;s2=sec2;end process s220;-1/10秒S10:process(clk,sec3)beginif clkevent and clk=1 then if sec3=1001 then sec3=0000; else sec3=sec3+1; end if; end if;s3doutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdou

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论