全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity clock is port (clk,clr,a,c,e,f,g:in std_logic; -输入信号 led_sel:out std_logic_vector( 2 downto 0); -位控输入信号 led:out std_logic_vector( 0 to 6); -七段码输出 min_tune,hour_tune:in std_logic; -十/个位置数 hour,min,sec:in std_logic; -时/分/秒选择 ing:out std_logic ); -蜂鸣器输出end entity clock;architecture beha of clock is signal m:integer range 0 to 999; signal hou1,hou0,min1,min0,sec1,sec0,s2: std_logic_vector(3 downto 0); signal rhou1,rhou0,rmin1,rmin0,rsec1,rsec0: std_logic_vector(3 downto 0); signal s1:std_logic_vector(2 downto 0); signal b:std_logic_vector(2 downto 0); signal clk1,clk2,d1,d2:std_logic; signal p,q:std_logic_vector(3 downto 0); signal n:integer range 0 to 1; beginp1:process(clk) begin if(rising_edge(clk1) then if hour_tune=0 then if q=1001 then q=0000;p=p+1; else q=q+0001; end if; if p=0010 then p=0000; end if; end if; ifmin_tune=0 then if q=1001 then q=0000;p=p+1; else q=q+0001; if p=0101 then p=0000; end if; end if; end if; end if; if (rising_edge(clk) then if hour=1 then b=010; end if; if min=1 then b=001; end if; if sec=1 then b=000; end if; if n=1 then n=0;clk2=1; else n=n+1; clk2=0; end if; end if ; end process; p2:process(clk) begin if (rising_edge(clk) then if m=999 then m=0;clk1=1; else m=m+1; clk1=0; end if; end if ; end process; p3: process(clk1,clr) begin if (clr=0) then sec0=0000;sec1=0000; min0=0000;min1=0000; hou0=0000;hou1=0000; elsif rising_edge(clk1) then if a=1 then -较时 if b=000 then sec1=p; sec0=q; -秒赋植 elsif b=001 then min1=p; min0=q; -分赋值 elsif b=010 then hou1=p; hou0=q; -小时赋值 end if; end if; if sec0=1001 then -计数部分 sec0=0000; if sec1=0101 then sec1=0000; if min0=1001 then min0=0000; if min1=0101 then min1=0000; if g=0 then if hou10010 then if hou0=1001 then hou0=0000;hou1=hou1+1 ; else hou0=hou0+1; end if; elsif hou1=0010 and hou0=0011 then hou1=0000; hou0=0000; else hou0=hou0+1; end if ; end if; if g=1 then if hou1=0001 then if hou0=1001 then hou0=0000;hou1=hou1+1 ; else hou0=hou0+1; end if; elsif hou1=0001 and hou0=0001 then hou1=0000; hou0=0000; else hou0=hou0+1; end if ; end if; else min1=min1+1; end if; else min0=min0+1; end if; else sec1=sec1+1; end if; else sec0=sec0+1; end if; end if ; end process;p4:process(clk) -数码管选通 begin if(rising_edge (clk) then if s1=111 then s1=000; else s1=s1+1; end if; end if; - led_sels2=sec0;led_sels2=sec1;led_sels2=min0;led_sels2=min1;led_sels2=hou0;led_sels2=hou1;led_selnull; end case; elsif f=1 then -显示闹铃时间 case s1 is when 010=s2=rmin0;led_sels2=rmin1;led_sels2=rhou0;led_sels2=rhou1;led_selnull; end case; end if; end process;p6:process(s2)begin if(s1ledledledledledledledledledlednull;end case ;else led=0000000;end if;end process;p7:process(clk1,c) -整点报时beginif (rising_edge(clk)thenif c=1 thenif (min1=0101 and min0=1001 and sec1=0101) then if(sec0=0000or sec0=0010 or sec0=0100 or sec0=0110 or sec0=1000)then d1=1 and clk2; -前四声相同 else d1=0; end if;elsif (min1=0000 and min0=0000 and sec0=0000 and sec1=0000) then d1=1; -最后一声高else d1=0;end if ;end if ;end if ;end process; p8:process(clk,e) -闹铃设置beginif (rising_edge(clk)thenif e=1 thenif b=001 then rmin1=p;rmin0=q;elsif b=100 then rhou1=p;rhou0=q;end if;end if;end if;end process;p9:process(clk,e) -闹铃比较begin if(rising_edge(clk)thenif e=1 thenif(rhou1=hou1 and rhou0=hou0 and rmin1=min1 and rmin0=min0)thenif(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 云计算转型实践研究-洞察与解读
- 人机交互伦理问题-洞察与解读
- 数字矿区空间信息集成技术-洞察与解读
- 酒店物联网数据隐私保护-洞察与解读
- 工程项目安全生产培训课件
- 篮球课安全教育课件
- 三年(2023-2025)中考化学真题分类汇编(全国):专题22 实验探究题(原卷版)
- 江苏省常州市2025-2026学年高三上学期11月期中考试政治试卷
- 护理质量安全管理数质量课件
- 科研项目完成合同
- 清华大学接受国内访问学者申请表
- QC19032201 质量控制分析报告 输入功率 输入电流 功率因数试验
- 超星尔雅《葡萄酒与西方文化》期末考试答案
- 小学数学专题讲座(课堂PPT)
- 重症患者SOFA评分表
- -热力学第一定律课件
- 信息论 信息熵课件
- 微机原理与接口技术课件全套
- 老年人睡眠障碍的特点与诊治
- 领导之道-高建华课件
- 低压配电柜培训ppt课件
评论
0/150
提交评论