




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、电子时钟:电子时钟的功能:可以显示时间,还可以修改时间。结构图no.7:此电路适合于设计时钟、定时器、秒表等。因为可利用键8和键5分别控制时钟的清零和设置时间的使能;利用键7、5和1进行时、分、秒的设置。实验代码:模块一:时间显示/clk:秒功能的时钟信号,为1hz的脉冲信号/time_set_en:时间设置使能信号/time_clear(键8):时钟显示的清零/hourh_set,hourl_set,minh_set,minl_set,sech_set,secl_set:设置后的小时、分、秒/hourh,hourl:小时的高低位/minh,minl:分的高低位/sech,secl:秒的高低位
2、/cout:进位输出,即计满24小时,向天产生的进位输出信号module time_count(clk,time_set_en,time_clear,hourh_set,hourl_set,minh_set,minl_set,sech_set,secl_set,hourh,hourl,minh,minl,sech,secl);input clk;input time_set_en,time_clear;input3:0hourh_set,hourl_set,minh_set,minl_set,sech_set,secl_set;output3:0hourh,hourl,minh,minl,se
3、ch,secl;reg3:0hourh,hourl,minh,minl,sech,secl;reg c1,c2; /c1和c2分别为秒向分,分向时的进位always(posedge time_set_en or posedge clk or posedge time_clear) begin if(time_set_en) /time_set_en:时间设置使能信号 begin sech<=sech_set; secl<=secl_set; minh<=minh_set; minl<=minl_set; hourh<=hourh_set; hourl<=ho
4、url_set; end else if(time_clear) /time_clear(键8):时钟显示的清零 begin hourh<=0; hourl<=0; minh<=0; minl<=0; sech<=0; secl<=0; end else begin if(secl=9) /sech,secl:秒的高低位设置 begin secl<=0; if(sech=5) begin sech<=0; c1<=1; if(minl=9) /minh,minl:分的高低位设置 begin minl<=0; if(minh=5) be
5、gin minh<=0; c2<=1; if(hourh=2)&&(hourl=3) begin hourh<=0; hourl<=0; end if(hourl=9) /hourh,hourl:小时的高低位设置 begin hourl<=0; if(hourh=2) hourh<=0; else hourh<=hourh+1; end else begin hourl<=hourl+1; end end else begin minh<=minh+1; end end else begin minl<=minl+1;
6、 c2<=0; end end else begin sech<=sech+1; end end else begin secl<=secl+1; c1<=0; end end endendmodule模块二:时间设置/key7:设置数码管8和7/key4:设置数码管5和4/key1:设置数码管2和1/time_set_en(键5):设置时间的使能端/hourh_set,hourl_set,minh_set,minl_set,sech_set,secl_set:设置后的小时、分、秒/hourh,hourl,minh,minl,sech,secl:当前的小时,分,秒mod
7、ule time_set(key7,key4,key1,time_set_en,hourh,hourl,minh,minl,sech,secl,hourh_set,hourl_set,minh_set,minl_set,sech_set,secl_set);input key7,key4,key1;input time_set_en;input3:0hourh,hourl,minh,minl,sech,secl;output3:0hourh_set,hourl_set,minh_set,minl_set,sech_set,secl_set;reg3:0hourh_set,hourl_set,m
8、inh_set,minl_set,sech_set,secl_set;always(posedge time_set_en) begin if(key7) begin if(hourh_set=2)&&(hourl_set=3) begin hourh_set<=0; hourl_set<=0; end else if(hourl_set=9) begin hourl_set<=0; if(hourh_set=2) hourh_set<=0; else hourh_set<=hourh_set+1; end else begin hourl_set
9、<=hourl_set+1; end end else if(key4) begin if(minl_set=9) begin minl_set<=0; if(minh_set=5) begin minh_set<=0; end else minh_set<=minh_set+1; end else begin minl_set<=minl_set+1; end end else if(key1) begin if(secl_set=9) begin secl_set<=0; if(sech_set=5) begin sech_set<=0; end
10、else sech_set<=sech_set+1; end else secl_set<=secl_set+1; end else begin hourh_set<=hourh; hourl_set<=hourl; minh_set<=minh; minl_set<=minl; sech_set<=sech; secl_set<=secl; end endendmodule模块三:顶层模块/clk:时间计数的时钟信号/time_set_en:设置时间使能信号/time_clear:显示时间清零使能信号/hourh,hourl,minh,minl
11、,sech,secl:当前或设置后的小时,分,秒/key7:设置数码管8和7/key4:设置数码管5和4/key1:设置数码管2和1module time_and_set(clk,time_set_en,time_clear,hourh,hourl,minh,minl,sech,secl,key7,key4,key1);input clk;input time_set_en,time_clear;input key7,key4,key1;output3:0 hourh,hourl,minh,minl,sech,secl;wire3:0hh,hl,mh,ml,sh,sl;wire3:0hh_se
12、t,hl_set,mh_set,ml_set,sh_set,sl_set;time_count u1( .clk(clk),.time_set_en(time_set_en),.time_clear(time_clear),.hourh_set(hh_set),.hourl_set(hl_set),.minh_set(mh_set),.minl_set(ml_set),.sech_set(sh_set),.secl_set(sl_set),.hourh(hourh),.hourl(hourl),.minh(minh),.minl(minl),.sech(sech),.secl(secl);time_set u2(.key7(key7),.key4(key4),.key1(key1),.time_set_en(time_set_en),.hourh_set(hh_set),.hourl_set(hl_set),.minh_set(mh_set),.minl_set(ml_set),.sech_set(sh_set),.secl_set(sl_set),.hourh(hou
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025办公设备租赁合同
- 2025年环境、健康与安全工程合同管理协议范本
- 2025年马铃薯购销合同
- 《触电事故的急救与防范》课件
- 《绿色建筑节能技术》课件
- 《黄斑变性病人的护理》课件
- 《我国投资环境分析》课件
- 《中华人民共和国劳动基准法》课件
- 《中国的文化遗产课件》课件
- 2025年百色货运资格证试题及答案
- 2012年7月国家开放大学专本科《法律文书》期末纸质考试试题及答案
- 统编版语文六年级下册第一单元“民风民俗”作业设计
- 双全日培训课件
- 甲油胶行业报告
- 医务人员职业暴露与防护讲课
- 山东省莱西市2024-2025学年高一语文下学期3月月考试题含解析
- 康复科人员岗位考核制度(3篇)
- 实验动物生物样本质量控制规范
- 智能机器人配送行业现状分析及未来三至五年行业发展报告
- 炎症性肠病的外科治疗
- 复变函数与积分变换课程教案讲义
评论
0/150
提交评论