多功能数字钟的设计报告_第1页
多功能数字钟的设计报告_第2页
多功能数字钟的设计报告_第3页
多功能数字钟的设计报告_第4页
多功能数字钟的设计报告_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

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

文档简介

1、 多功能数字钟的设计报告一、 设计任务使用硬件描述语言,在CPLD/FPGA上实现一个多功能数字钟。二、 设计要求除按键、LED、扬声器、时钟信号外,整个数字钟的功能要求在一块芯片上实现。a) 具有时,分,秒,计数显示功能,以24小时循环计时;b) 具有时间清零功能;c) 具有小时、分钟和秒钟调整功能(个位和十位分开调或合起来调)。d) 具有闹钟功能,能预设闹钟时间,精确到秒。e) 整个数字钟只设一个时钟输入端口,所需不同频率信号在内部分频实现。(LED扫描频率设为50Hz以上)三方案I.总体方案分析:整个电路有三大主体电路:1. 控制电路,2.脉冲电路,3,功能电路时钟电路首先要有输入脉冲,

2、由于平台提供了脉冲发生器,就省去了脉冲发生器的设计,这里我们只需要设计一个分频器,得到我们需要的频率。时钟的计时范围是00:00:00-23:59:59,所以我们需要设计模六十和模二十四的计数器组成时钟计时电路。为了显示当前时钟时间,我们需要一个显示电路。校分、校时、清零电路只需要输入一些控制信号给时钟计时电路即可,当然这些控制信号是由开关提供的。要实现整点报时功能,一个报时控制电路是必不可少的。这是只含基本功能的时钟电路所包含的子电路。为了实现我们加入的闹钟功能,我们需要一个闹钟时间设定电路;闹钟时间保持电路;比较电路;蜂鸣器控制电路;闹表时间显示电路。因为我们只含有一个数码显示器,一般状态

3、下显示的是时钟,所以我们需要一个显示模式切换电路。module decoder_38(out,in);output7:0 out;input2:0 in;reg7:0 out;always (in)begincase(in)3'd0: out=8'b11111110;3'd1: out=8'b11111101;3'd2: out=8'b11111011;3'd3: out=8'b11110111;3'd4: out=8'b11101111;3'd5: out=8'b11011111;3'd6

4、: out=8'b10111111;3'd7: out=8'b01111111;endcaseendendmodulemodule fenpinqi(CP,CP_1HZ,CP_1KHZ);input CP;output CP_1HZ,CP_1KHZ;reg CP_1HZ,CP_1KHZ;integer cnt=0,cnt1=0;always(posedge CP)begin/cnt<=49999999if(cnt<=49999999)beginCP_1HZ<=1'b0;cnt=cnt+1;endelsebeginCP_1HZ<=1'

5、;b1;cnt=0; endendalways(posedge CP)begin/cnt1<=4999if(cnt1<=4999)beginCP_1KHZ<=1'b0;cnt1=cnt1+1;endelsebeginCP_1KHZ<=1'b1;cnt1=0; endendendmodulemodule kongzhiqi( CP_1HZ,S1,S2,RET,Hour,Minute,Second);input CP_1HZ,S1,S2,RET;output 5:0 Hour;output 5:0 Minute;output 5:0 Second;reg 5

6、:0 Hour;reg 5:0 Minute;reg 5:0 Second;reg R1,R2,R8;always (posedge CP_1HZ)begin if(S1=0) begin R1=1; end if(S2=0) begin R2=1; end if(RET=0) begin R8=1; end if(R1=1) begin if(Hour<6'b11_000) Hour=Hour+6'b1; begin if(Hour=6'b11_000) Hour=0; end R1=0; end if(R2=1) begin if(Minute<6

7、9;b111_100) Minute=Minute+6'b1; if(Minute=6'b111_100) begin Minute=0; end R2=0; end if(Second<6'b1111_00) begin Second=Second+6'b1; end if(R8=1)&&(CP_1HZ)/清零 begin Hour=0; Minute=0; Second=0; R8=0; end if(Hour=6'b101_11)&&(Minute=6'b1110_11)&&(Secon

8、d=6'b1110_11) begin Hour=6'b0; Minute=6'b0; Second=6'b0; end if(Hour<6'b101_11)&&(Minute=6'b1110_11)&&(Second=6'b1110_11) begin Hour=Hour+6'b1; Minute=6'b0; Second=6'b0; end if(Minute<6'b1110_11)&&(Second=6'b1111_00) begin

9、 Minute=Minute+6'b1; Second=6'b0; end endendmodulemodule xianshiqi( CPout,Hour,Minute,Second,SEL,LEDAG );input CPout;input 5:0 Hour;input 5:0 Minute;input 5:0 Second;output 2:0 SEL;output 6:0LEDAG;reg 2:0 SEL;reg 6:0 Led;reg 3:0 shiwei1,gewei1,shiwei2,gewei2,shiwei3,gewei3;always (posedge CP

10、out )begin shiwei1=Hour/10; gewei1=Hour%10; shiwei2=Minute/10; gewei2=Minute%10; shiwei3=Second/10; gewei3=Second%10; if(SEL=3'b000) /判断位选SEL的值,并将此位上的值输出到数码管case(shiwei1) 4'b0000: Led = 7'b1000_000; 4'b0001: Led = 7'b1111_001; 4'b0010: Led = 7'b0100_100; 4'b0011: Led

11、= 7'b0110_000; 4'b0100: Led = 7'b0011_001; 4'b0101: Led = 7'b0010_010; 4'b0110: Led = 7'b0000_010; 4'b0111: Led = 7'b1111_000; 4'b1000: Led = 7'b0000_000; 4'b1001: Led = 7'b0010_000; default: Led = 7'b1111_111;endcase if(SEL=3'b001)case(gew

12、ei1) 4'b0000: Led = 7'b1000_000; 4'b0001: Led = 7'b1111_001; 4'b0010: Led = 7'b0100_100; 4'b0011: Led = 7'b0110_000; 4'b0100: Led = 7'b0011_001; 4'b0101: Led = 7'b0010_010; 4'b0110: Led = 7'b0000_010; 4'b0111: Led = 7'b1111_000; 4'b

13、1000: Led = 7'b0000_000; 4'b1001: Led = 7'b0010_000; default: Led = 7'b1111_111; endcase if(SEL=3'b010) Led=7'b1111_111; if(SEL=3'b011) case(shiwei2) 4'b0000: Led = 7'b1000_000; 4'b0001: Led = 7'b1111_001; 4'b0010: Led = 7'b0100_100; 4'b0011: L

14、ed = 7'b0110_000; 4'b0100: Led = 7'b0011_001; 4'b0101: Led = 7'b0010_010; 4'b0110: Led = 7'b0000_010; 4'b0111: Led = 7'b1111_000; 4'b1000: Led = 7'b0000_000; 4'b1001: Led = 7'b0010_000; default: Led = 7'b1111_111; endcase if(SEL=3'b100) cas

15、e(gewei2) 4'b0000: Led = 7'b1000_000; 4'b0001: Led = 7'b1111_001; 4'b0010: Led = 7'b0100_100; 4'b0011: Led = 7'b0110_000; 4'b0100: Led = 7'b0011_001; 4'b0101: Led = 7'b0010_010; 4'b0110: Led = 7'b0000_010; 4'b0111: Led = 7'b1111_000; 4&

16、#39;b1000: Led = 7'b0000_000; 4'b1001: Led = 7'b0010_000; default: Led = 7'b1111_111; endcase if(SEL=3'b101) Led=7'b1111_111; if(SEL=3'b110) case(shiwei3) 4'b0000: Led = 7'b1000_000; 4'b0001: Led = 7'b1111_001; 4'b0010: Led = 7'b0100_100; 4'b00

17、11: Led = 7'b0110_000; 4'b0100: Led = 7'b0011_001; 4'b0101: Led = 7'b0010_010; 4'b0110: Led = 7'b0000_010; 4'b0111: Led = 7'b1111_000; 4'b1000: Led = 7'b0000_000; 4'b1001: Led = 7'b0010_000; default: Led = 7'b1111_111; endcase if(SEL=3'b111) case(gewei3) 4'b0000: Led = 7'b1000_000; 4'b0001: Led = 7'b1111_001; 4'b0010: Led = 7'b0100_100; 4'b0011: Led = 7'b0110_000; 4'b0100: Led = 7'b001

温馨提示

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

评论

0/150

提交评论