




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、分频module clkgen (clock,reset,clkdiv,clk500;input clock,reset;output clkdiv;output clk500;reg 31:0 counter1;reg clkdiv;reg clk500;reg 31:0 counter0;/*?1HZ?*/always(posedge clockif(resetbeginclkdiv<=0;counter0<=0;endelse if(counter0=24'd4begincounter0<=0;clkdiv=clkdiv;endelsebegincounter0
2、<=counter0+1;clkdiv<=clkdiv;end/*?500HZ?*/always(posedge clock if(resetbeginclk500<=0;counter1<=0;endelse if(counter1=24'd2begincounter1<=0;clk500=clk500;endelsebegincounter1<=counter1+1;clk500<=clk500;endendmodule计数module jishu24(clkdiv,clear,second,s_carry,minute,m_carry,h
3、our,sL,sH,mL,mH,hL,hH; input clkdiv,clear;output 5:0 second,minute;output 4:0 hour;output s_carry,m_carry;output sL,sH,mL,mH,hL,hH;reg s_carry,m_carry;reg 5:0 second,minute;reg 4:0 hour;reg sL,sH,mL,mH,hL,hH;always(posedge clkdiv or clearif(clearsecond<=0;else if(second!=6'b111011beginsecond&
4、lt;=second+1;s_carry<=0;endelsebeginsecond<=0;s_carry<=1;endalways(posedge s_carry or clearif(clearminute<=0;else if(minute!=6'b111011beginminute<=minute+1;m_carry<=0;endelsebeginminute<=0;m_carry<=1;endalways (posedge m_carry or clearif(clearhour<=0;else if(hour!=5
5、9;b10111beginhour<=hour+1;endelsebeginhour<=0;endalways(posedge secondbeginsL<=second%10;sH<=second/10;endalways(posedge minutebeginmL<=minute%10;mH<=minute/10;endalways(posedge hourbeginhL<=hour%10;hH<=hour/10;endendmodule显示module decode(clk500,reset,hH,hL,mH,mL,sH,sL,HIGH,L
6、OW,COM;input clk500;input reset;input hH,hL;/?input mH,mL;/?input sH,sL;/?output 6:0 HIGH,LOW;/?output 7:0 COM;/?reg 7:0 show_temp_H,show_temp_L;/?reg 7:0 COM;reg 7:0 Uweixuan;/?COM?reg 2:0 sm;/?reg 6:0 HIGH;/?reg 6:0 LOW;/?always(posedge clk500beginif(sm=3'b111sm<=3'b000;elsesm<=sm+3&
7、#39;b001;Uweixuan<=Uweixuan<<1;/?if(Uweixuan=8'b0000_0000Uweixuan<=8'b0000_0001; /?Uweixuan?COM=Uweixuan;/?Uweixuan?endalways(smbegincase(COM8'b1111_1110:show_temp_H=sL;/?8'b1111_1101:show_temp_H=sH;8'b1111_1011:show_temp_H=4'b1010;8'b1111_0111:show_temp_H=mL;
8、8'b1110_1111:show_temp_L=mH;8'b1101_1111:show_temp_L=4'b1010;8'b1011_1111:show_temp_L=hL;8'b0111_1111:show_temp_L=hH;/?endcaseendalways(show_temp_H/?begincase(show_temp_H4'b0000: HIGH=7'b011_1111;4'b0001: HIGH =7'b000_0110;4'b0010: HIGH =7'b101_1011;4'
9、b0011: HIGH =7'b100_1111;4'b0100: HIGH =7'b110_0110;4'b0101: HIGH =7'b110_1101;4'b0110: HIGH =7'b111_1101;4'b0111: HIGH =7'b000_0111;4'b1000: HIGH =7'b111_1111;4'b1001: HIGH =7'b110_1111;4'b1010: HIGH =7'b100_0000;default HIGH =7'b000_0
10、000;endcaseendalways(show_temp_L/?begincase(show_temp_L4'b0000:LOW=7'b011_1111;4'b0001: LOW =7'b000_0110;4'b0010: LOW =7'b101_1011;4'b0011: LOW =7'b100_1111;4'b0100: LOW =7'b110_0110;4'b0101: LOW =7'b110_1101;4'b0110: LOW =7'b111_1101;4'b01
11、11: LOW =7'b000_0111;4'b1000: LOW =7'b111_1111;4'b1001: LOW =7'b110_1111;4'b1010: LOW =7'b100_0000;default LOW =7'b000_0000;endcaseendendmodule主函数实现各函数的调用module main(clock,reset,HIGH,LOW,COM;input clock;input reset;output 6:0 HIGH,LOW;output 7:0 COM;endmodulemodule cl
12、kgen (clock,reset,clkdiv,clk500; input clock,reset;output clkdiv;output clk500;reg 23:0 counter1;reg clkdiv;reg clk500;reg 23:0 counter0;/*?1HZ?*/ always(posedge clockif(resetbeginclkdiv<=0;counter0<=0;endelse if(counter0=24'd4begincounter0<=0;clkdiv=clkdiv;endelsebegincounter0<=coun
13、ter0+1;clkdiv<=clkdiv;end/*?500HZ?*/ always(posedge clock if(resetbeginclk500<=0;counter1<=0;endelse if(counter1=24'd2begincounter1<=0;clk500=clk500;endelsebegincounter1<=counter1+1;clk500<=clk500;endendmodulemodule jishu24(clkdiv,clear,second,s_carry,minute,m_carry,hour,sL,sH,
14、mL,mH,hL,hH; input clkdiv,clear;output 5:0 second,minute;output 4:0 hour;output s_carry,m_carry;output sL,sH,mL,mH,hL,hH;reg s_carry,m_carry;reg 5:0 second,minute;reg 4:0 hour;reg sL,sH,mL,mH,hL,hH;always(posedge clkdiv or clearif(clearsecond<=0;else if(second!=6'b111011beginsecond<=second
15、+1;s_carry<=0;endelsebeginsecond<=0;s_carry<=1;endalways(posedge s_carry or clearif(clearminute<=0;else if(minute!=6'b111011beginminute<=minute+1;m_carry<=0;endelsebeginminute<=0;m_carry<=1;endalways (posedge m_carry or clearif(clearhour<=0;else if(hour!=5'b10111be
16、ginhour<=hour+1;endelsebeginhour<=0;endalways(posedge secondbeginsL<=second%10;sH<=second/10;endalways(posedge minutebeginmL<=minute%10;mH<=minute/10;endalways(posedge hourbeginhL<=hour%10;hH<=hour/10;endendmodulemodule shumaguan(clk500,reset1,hH,hL,mH,mL,sH,sL,HIGH,LOW,COM;i
17、nput clk500;input reset1;input hH,hL;/?input mH,mL;/?input sH,sL;/?output 6:0 HIGH,LOW;/?output 7:0 COM;/?reg 7:0 show_temp_H,show_temp_L;/?reg 7:0 COM;reg 7:0 Uweixuan;/?COM?reg 2:0 sm;/?reg 6:0 HIGH;/?reg 6:0 LOW;/?always(posedge clk500beginif(sm=3'b111sm<=3'b000;elsesm<=sm+3'b00
18、1;Uweixuan<=Uweixuan<<1;if(Uweixuan=8'b0000_0000Uweixuan<=8'b0000_0001; /?Uweixuan? COM=Uweixuan;/?Uweixuan?endalways(clk500begincase(COM8'b1111_1110:show_temp_H=sL;/?8'b1111_1101:show_temp_H=sH;8'b1111_1011:show_temp_H=4'b1010;8'b1111_0111:show_temp_H=mL;8
19、9;b1110_1111:show_temp_L=mH;8'b1101_1111:show_temp_L=4'b1010;8'b1011_1111:show_temp_L=hL;8'b0111_1111:show_temp_L=hH;/?endcaseendalways(show_temp_H/?begincase(show_temp_H4'b0000: HIGH=7'b011_1111;4'b0001: HIGH =7'b000_0110;4'b0010: HIGH =7'b101_1011;4'b001
20、1: HIGH =7'b100_1111;4'b0100: HIGH =7'b110_0110;4'b0101: HIGH =7'b110_1101;4'b0110: HIGH =7'b111_1101;4'b0111: HIGH =7'b000_0111;4'b1000: HIGH =7'b111_1111;4'b1001: HIGH =7'b110_1111;4'b1010: HIGH =7'b100_0000;default HIGH =7'b000_0000;
21、 endcaseendalways(show_temp_L/?begincase(show_temp_L4'b0000: LOW =7'b011_1111;4'b0001: LOW =7'b000_0110;4'b0010: LOW =7'b101_1011;4'b0011: LOW =7'b100_1111;4'b0100: LOW =7'b110_0110;4'b0101: LOW =7'b110_1101;4'b0110: LOW =7'b111_1101;4'b0111: LOW =7'b000_0111;4'b1000: LOW =7'b111_1111;4'b1
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 吉林省靖宇县2025届化学高二下期末达标检测试题含解析
- 骨折术后感染控制策略-洞察及研究
- 领导力对文化传播影响-洞察及研究
- 醋酸白试验数据挖掘与智能诊断技术研究-洞察阐释
- 长寿命路面结构设计技术-洞察阐释
- 电商对农民心理素质影响-洞察阐释
- 健康管理APP用户体验优化-洞察阐释
- 伦理监管政策创新-洞察及研究
- 零售返修品再制造优化策略-洞察阐释
- 2025届安徽省合肥市一六八中化学高一下期末调研模拟试题含解析
- T∕CITS 146-2024 尿液有形成分名称与结果报告规范化指南
- 农药经营考试题及答案
- 2025年中考安徽物理试题及答案
- 标前合作合同范本
- 2025年初级钢筋工(五级)技能认定理论考试指导题库(含答案)
- 国家开放大学汉语言文学本科《古代诗歌散文专题》期末纸质考试第四大题论述题库2025春期版
- 2024秋新科粤版化学九年级上册教学课件 2.2 构成物质的微观粒子 第4课时 相对原子质量 离子的形成
- 魅力沟通技巧课件
- 宠物店合伙协议书范本
- 国家开放大学法律事务专科《民法学(1)》期末纸质考试总题库2025春期考试版
- 2025年度资料员劳动合同范本(含试用期管理规定)
评论
0/150
提交评论