ImageVerifierCode 换一换
格式:DOCX , 页数:27 ,大小:21.25KB ,
资源ID:9315660      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-9315660.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(基于VHDL的电子钟设计.docx)为本站会员(b****0)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

基于VHDL的电子钟设计.docx

1、基于VHDL的电子钟设计E D A课 程 设 计题目:利用VHDL进行电子钟设计院系:物理工程学院专业班级: 学生姓名: 学生学号:2010年6月3 日一、设计要求:功能:显示年月日、星期、时分秒、闹钟和整点报时(几点响几下),并且所有显示均可调。二、设计原理:1)模块设计:根据要求可将实验分成三个大的模块:年月日,时分秒和闹钟。时分秒:时、分、秒分为三个独立模块,同时秒的脉冲为1HZ,秒进位作为分的时钟信号, 分进位作为时的时钟信号,时进位作为日和星期的时钟信号。年月日:日进位作为月的时钟信号,月进位作为年的时钟信号。由于年、月、日三者之 间存在反馈机制(即闰年与非闰年有差别,大月与小月间有

2、差别),故将它们放在同一 个模块中。闹钟和整点报时具有相似性,故归为一类。总共需要13个独立模块。2):显示设计: 根据实验箱上只有8个LED数码管的具体情况,将显示分三种模式显示出来:(1)星 期、时分秒;(2)年月日;(3)闹钟时间。3):按键设计:共设计5个按键:J8键:高电平显示年月日,低电平显示星期、时分秒。 J7键:高电平显示闹钟。 J5键:系统复位键,高电平有效。 J3键:可调区域选择键,高电平有效,选中可调区域相应灯亮。 J1键:累加键,高电平有效,可调区域实现累加。4):报时设计:蜂鸣器在整点报时时几点响几下,闹时响一分钟。5): 时钟设计:秒和时钟clk接1HZ,其它模块c

3、lk1接2HZ。6): 模式设计:实验箱选择模式5。三、注意事项:1:由于本设计采用了两个不同频率的时钟,所以在刚下载完程序后会发现所有数码管都在跑动。解决办法:按下J3键,将各个模块扫描一遍。2:xian1中输出的res需和J5的reset经过一个或门后输出,再与各模块的reset相连。四:实验程序:-秒计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity second is port(clk,setmin,reset,clk1:in std_logic; -clk接1HZcloc

4、k0,clk1为按键触发时钟,接2HZclk2 seout:out std_logic_vector(6 downto 0); enmin:out std_logic); end entity second;architecture one of second issignal count:std_logic_vector(6 downto 0);signal enmin1,enmin2:std_logic;-enmin1为59秒时进位信号,enmin2 由clk1调制后的手动调分脉冲 begin seout=count; enmin2=(setmin and clk1); enmin=(en

5、min1 or enmin2);process(clk,reset,setmin)begin if(reset=1)then count=0000000; elsif(clkevent and clk=1)then if(count(3 downto 0)=1001)then if(count16#60#)then-即,为进制数写法,此步是必须的 if(count=1011001)then enmin1=1;count=0000000;-如果count已经到了,则置进位为及count为 else count=count+7;-则加,由09h变为10h end if; else count60h

6、,为无效操作 end if; elsif(count16#60#)then count=count+1; enmin1=0; else count=0000000; end if; end if;end process;end one; -分计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity min is port(clk,sethour,reset,clk1:in std_logic; miout:out std_logic_vector(6 downto 0); enhour:

7、out std_logic); end entity min;architecture one of min issignal count:std_logic_vector(6 downto 0);signal enhour1,enhour2:std_logic;-enhour1为59秒时进位信号,enhour2 由clk2调制后的手动调分脉冲 begin miout=count; enhour2=(sethour and clk1); enhour=(enhour1 or enhour2);process(clk,reset,sethour)begin if(reset=1)then cou

8、nt=0000000; elsif(clkevent and clk=1)then if(count(3 downto 0)=1001)then if(count16#60#)then if(count=1011001)then enhour1=1;count=0000000; else count=count+7; end if; else count=0000000; end if; elsif(count16#60#)then count=count+1; enhour1=0; else count=0000000; end if; end if;end process;end one;

9、-时计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour is port(clk,clk1,setda,setweek,reset:in std_logic; enda,enweek:out std_logic; hout:out std_logic_vector(5 downto 0);end entity hour;architecture fun of hour is signal count:std_logic_vector(5 downto 0); signal

10、jwd1,jwd2,jwd3:std_logic;-jwd1是进位信号,jwd1是天,jwd2是星期begin hout=count; jwd2=(setda and clk1); jwd3=(setweek and clk1); enweek=(jwd1 or jwd3); enda=(jwd1 or jwd2);process (clk,reset,setda,setweek) begin if(reset=1)then count=000000; elsif(clkevent and clk=1)then if(count(3 downto 0)=1001)then if(count16

11、#23#)then-注意这里的写法与前面有一点不同,后面模块如此。 count=count+7; else count=000000; end if; elsif(count=100011)then jwd1=1;count=000000; elsif(count16#23#)then count=count+1; jwd1=0 ; else count=000000; end if; end if;end process;end fun;-星期library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;en

12、tity week is port (clk,reset:in std_logic; weout:out std_logic_vector(2 downto 0);end entity week;architecture one of week is signal count:std_logic_vector(2 downto 0);begin weout=count;process (clk,reset)begin if(reset=1)then count=001; elsif(clkevent and clk=1)then if(count16#7#)then count=count+1

13、; else count=001; end if; end if;end process;end one;-年月日library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity dmy3 is port (reset,clk1,clk,setm,sety:in std_logic;-clk1为计数时钟信号,clk接前面hour输出信号 dtout:out std_logic_vector(5 downto 0); -dtout为日输出 mtout1:out std_logic_vector(4 do

14、wnto 0); -mtout为月输出 ytout:out std_logic_vector(15 downto 0); -ytout为年输出end entity dmy3;architecture one of dmy3 is signal countd:std_logic_vector(5 downto 0); signal countm:std_logic_vector(4 downto 0); signal county:std_logic_vector(7 downto 0); signal y1:std_logic_vector(3 downto 0); signal y2:std

15、_logic_vector(3 downto 0); signal day_out,month_out:std_logic;-程序内部天和月的进位,也可放于前面设为buffer signal mtout:std_logic_vector(4 downto 0); signal day_out1,day_out2,month_out1,month_out2:std_logic;begin dtout=countd; mtout=countm;-此处mtout的作用是后面作为一个数据的中转 mtout1=mtout; ytout(15 downto 8)=00100000; -年的前两位固定20,

16、显示为16进制 ytout(7 downto 0)=county; -年的后面两位 y1=county(3 downto 0);-判断闰年的标志位 y2=county(7 downto 4); day_out2=(setm and clk1); -setm为手动调月控制信号、高电平有效 day_out=(day_out2 or day_out1); month_out2=(sety and clk1); -sety为手动调年控制信号、高电平有效 month_out=(month_out1 or month_out2);pro1:process (month_out,reset)-对年的设制 b

17、egin if(reset=1)then county=00000000; -若reset为1,则异步清零 elsif(month_outevent and month_out=1)then -否则,若month_out上升沿到 if(county(3 downto 0)=1001)then -若个位计数值恰好到“1001” if(county16#99#)then -又若count小于16#99#,共是100年 county=county+7; -则加7,9变为10 else county=00000000; -若count不小于16#99#,则count复0 end if; elsif(c

18、ounty16#99#)then -若各位计数未到“1001”则转到此句再判断; county=county+1; -否则若count16#99#,count加1 else county=00000000; -则count复0(此句对无效状态电路可自启动) end if; -end if(count(3 downto 0)=“1001”) end if; -end if(reset=1) end process;pro2:process (day_out,reset,sety)-对月的调制 begin if(reset=1)then countm=00001;-1月,初始状态 elsif(da

19、y_outevent and day_out=1)then if(countm(3 downto 0)=1001)then if(countm16#12#)then countm=countm+7; else countm=00001; end if; elsif(countm=10010)then month_out1=1;countm=00001; elsif(countm16#12#)then countm=countm+1; month_out1=0; else countm=00001; end if; end if; end process;pro3:process (clk,re

20、set,setm)-小时的输出 begin if(reset=1)then countd=000001; elsif(clkevent and clk=1)then if(mtout=1 or mtout=3 or mtout=5 or mtout=7 -大月份31天 or mtout=8 or mtout=10 or mtout=12)then if(countd(3 downto 0)=1001)then -末尾是9时 if(countd16#32#)then countd=countd+7; -十进制调整 else countd=000001; end if; elsif(countd=

21、110001)then -到了第31天 day_out1=1;countd=000001; elsif(countd16#32#)then -末尾不是9 ,又未到第31天 countd=countd+1; day_out1=0 ; else countd=000001; end if; elsif(mtout=4 or mtout=6 or mtout=9 or mtout=11)then -小月份30天 if(countd(3 downto 0)=1001)then if(countd16#31#)then countd=countd+7; else countd=000001; end i

22、f; elsif(countd=110000)then-30天 day_out1=1;countd=000001; elsif(countd16#31#)then countd=countd+1; day_out1=0 ; else countd=000001; end if; Else -对闰年的判断 if(Y2=0 OR Y2=2 OR Y2=4 OR Y2=6 OR Y2=8)AND(Y1=0 OR Y1=4 OR Y1=8)OR (Y2=1 OR Y2=3 OR Y2=5 OR Y2=7 OR Y2=9)AND(Y1=2 OR Y1=6) THEN if(countd(3 downto

23、 0)=1001)then if(countd16#30#)then if(countd=101001)then day_out1=1;countd=000001; else countd=countd+7; end if; else countd=000001; end if; elsif(countd16#30#)then countd=countd+1; day_out1=0 ; else countd=000001; end if; else -不是闰年,二月份28天 if(countd(3 downto 0)=1001)then if(countd16#29#)then countd

24、=countd+7; else countd=000001; end if; elsif(countd=101000)then day_out1=1;countd=000001; elsif(countd16#29#)then countd=countd+1; day_out1=0 after 100ns; else countd=000001; end if; end if;-判断闰年的语句 end if;-判断月份的语句 end if; end process; end one;-整点报时library ieee;use ieee.std_logic_1164.all;use ieee.s

25、td_logic_unsigned.all;entity alarm is port (clk1:in std_logic; zmin,zse:in std_logic_vector(6 downto 0); hour:in std_logic_vector(5 downto 0); speak:out std_logic);end entity alarm;architecture one of alarm is signal count:std_logic_vector(5 downto 0); signal zhour:std_logic_vector(5 downto 0);-zhou

26、r将与hour进行比较,也可是buffer signal count1:std_logic_vector(1 downto 0);begin zhour=count;process(clk1)begin speak=count1(0); if(clk1event and clk1=1)then if(zse=0000000)then-当秒为0时,count为0,只有让分秒为开才有可能实现几点响几下 count=000000; end if; if(zmin=0000000 )then -且当分也为0时,开始让count计时,此时计时不受秒的影响 if(zhourhour)then-只有当内部计数小于hour时,才能使speak响,确保了几点响几下 if(count(3 downto 0)=1001)the

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2