EDA数字钟程序代码.doc_第1页
EDA数字钟程序代码.doc_第2页
EDA数字钟程序代码.doc_第3页
EDA数字钟程序代码.doc_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

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

文档简介

-分频器library ieee;use ieee.std_logic_1164.all;entity fenpin is port(clk:in std_logic; qH: buffer std_logic; qout:buffer std_logic);end entity;architecture c20 of fenpin is begin process(clk) variable num : integer :=1; variable num1 : integer :=1 begin if clkevent and clk=0 then if(num=2)-0000000) -1HZ-10000000 to timer then num:=1;qout=not qout; else num:=num+1; end if; if(num1=1)-000000) -1000HZ-10000 to wei then num1:=1;qH=not qH; else num1:=num1+1; end if; end if;end process;end c20;-timerlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity Clock3 is port(clk:in std_logic; duan: out std_logic_vector(3 downto 0); wei: in std_logic_vector(2 downto 0); wei2: out std_logic_vector(2 downto 0) );end entity;architecture clo of Clock3 is signal clk2:std_logic ; signal keys: std_logic_vector(2 downto 0); begin keys=key_h&key_m&key_s; clk2=clk or flag; process(key_que) begin if key_queevent and key_que=0 then flag if clk2event and clk2=0 then -正常计时 if scn=59 and min=59 and hor=23 then scn:=0;min:=0;hor:=0; elsif scn=59 and min=59 then scn:=0;min:=0;hor:=hor+1; elsif scn=59 then scn:=0;min:=min+1; else scn:=scn+1; end if; if min=59 -整点报时500hz then if scn=50 or scn=52 or scn=54 or scn=56 or scn=58 then music_out=musicL; else music_out=0; end if; elsif min=0 and scn=0-整点报时1000HZ then music_out=musicH; else music_out case keys is when 011 = if hor=23 then hor:=0; else hor:=hor+1; end if; -keys if min=59 then min:=0; else min:=min+1; end if; - keys if scn=59 then scn:=0; else scn:=scn+1; end if; - keys null;- keys=00; end case; end case; h:=hor/10; -除法,特别是取余数运算会占用很多逻辑资源 hH=0000+h; hL=0000+(hor-10*h); m:=min/10; mH=0000+m; mL=0000+(min-10*m); s:=scn/10; sH=0000+s; sL key_out key_out null; end case; end if; end process; key_qudou;-顶层文件 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity Clock is port( clk:in std_logic; music_out:out std_logic; key_in:in std_logic; keyh_in:in std_logic; keym_in:in std_logic; keys_in:in std_logic; duan: out std_logic_vector(6 downto 0); wei: buffer std_logic_vector(2 downto 0);end entity;architecture clo of Clock is component fenpin port(clk:in std_logic; musicH: buffer std_logic; musicL: buffer std_logic; qH: buffer std_logic; qM: buffer std_logic; qout:buffer std_logic); end component; component counter_8 port( clk: in std_logic; count: buffer std_logic_vector(2 downto 0); end component; component Clock3 port(clk:in std_logic; key_que:in std_logic; key_h:in std_logic; key_m:in std_logic; key_s:in std_logic; musicH:in std_logic; musicL:in std_logic; music_out:out std_logic; duan: out std_logic_vector(3 downto 0); wei: in std_logic_vector(2 downto 0); wei2: out std_logic_vector(2 downto 0) ); end component; component seg7dec port( din: in std_logic_vector(3 downto 0); qout:out std_logic_vector(6 downto 0);-a,b,c.f,g end component; component qudou port( clk,key_in:in std_logic; keyh_in:in std_logic; keym_in:in std_logic; keys_in:in std_logic; key_out:out std_logic; keyh_out:out std_logic; keym_out:out std_logic; keys_out:out std_logic); end component; begin u1: fenpin port map(clk=clk,qH=clkH,qout=clkL,qM=clkM,musicH=c_m_H,musicL=c_m_L); u2: counter_8 port map(clk=clkH,count=wei_in); u3: seg7dec port map(din=duan_in,qout=duan); u4: Clock3 port map(clk=clkL,duan=duan_in,wei=wei_in,wei2=wei,key_que=key0,key_h=key1,key_m=key2,key_s=key3,musicH=c_m_H,musicL=c_m_L

温馨提示

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

评论

0/150

提交评论