




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 耐火土石矿山开采对矿区生态环境的监测与预警考核试卷
- 木片在船舶建造中的应用考核试卷
- 探秘生态学实践
- 山西林业职业技术学院《红色经典音乐作品赏析》2023-2024学年第一学期期末试卷
- 江苏省扬州市江都区实验重点中学2024-2025学年初三下学期期末考质量调研(一模)生物试题含解析
- 山东省东平县重点名校2025年初三下学期第二次段考生物试题试卷含解析
- 山东省青岛市城阳九中学2024-2025学年初三下学期第四次月考生物试题含解析
- 辽宁省辽阳市2025年初三年级教学质量检测试题考试(二)生物试题试卷含解析
- 铁岭卫生职业学院《唐诗宋词鉴赏》2023-2024学年第二学期期末试卷
- 四川工商职业技术学院《休闲体育活动策划与案例分析》2023-2024学年第一学期期末试卷
- 2024年房屋代持协议书范本
- 2024厨房改造合同范本
- 2024年北京市中考模拟道德与法治试卷
- TZJATA 0025-2024 水质 总氮测定预制变色酸试剂分光光度法
- 提高护士应用PDA落实患者身份识别准确率 2
- 2024-2025学年八年级数学上册:构造三角形全等方法-作公共边、公共角、垂直
- 福建省能源石化集团有限责任公司招聘笔试题库2024
- 初一英语英语阅读理解专项训练15篇
- 鳌虾和蝗虫的比较解剖专家讲座
- 房产土地税培训课件
- 电子行业研发工程师劳动合同范本
评论
0/150
提交评论