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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

QuartusII时钟CASE语句.docx

1、QuartusII时钟CASE语句library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity szz isport(clk:in std_logic; clk1:in std_logic; md1:in std_logic; md2:in std_logic_vector(1 downto 0); speak:out std_logic; dout:out std_logic_vector(6 downto 0); selout:out std_logic_vector(2 downto 0);

2、end szz;architecture one of szz issignal sel:std_logic_vector(2 downto 0);signal hou1:std_logic_vector(3 downto 0);signal hou2:std_logic_vector(3 downto 0);signal min1:std_logic_vector(3 downto 0);signal min2:std_logic_vector(3 downto 0);signal seth1:std_logic_vector(3 downto 0);signal seth2:std_log

3、ic_vector(3 downto 0);signal setm1:std_logic_vector(3 downto 0);signal setm2:std_logic_vector(3 downto 0);signal sec1:std_logic_vector(3 downto 0);signal sec2:std_logic_vector(3 downto 0);signal h1:std_logic_vector(3 downto 0);signal h2:std_logic_vector(3 downto 0);signal m1:std_logic_vector(3 downt

4、o 0);signal m2:std_logic_vector(3 downto 0);signal s1:std_logic_vector(3 downto 0);signal s2:std_logic_vector(3 downto 0);-begin-模6计数choice:process(clk1)beginif clk1event and clk1=1 thenif sel=101 thensel=000;elsesel=sel+1;end if;end if;end process choice;-小时十位h110:process(clk,hou2,min1,min2,sec1,se

5、c2,md1,md2)beginif clkevent and clk=1 thenif (hou1=0010 and hou2=0011)and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001) thenhou1=0000;elsif hou1=0010and hou2=0011and md1=0 and md2=01 then-当时间为23点且处于校时状态时hou1=0000;elsif (hou2=1001and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001)or (

6、hou2=1001and md1=0 and md2=01) thenhou1=hou1+1;end if;end if;end process h110;-小时个位h220:process(clk,min1,min2,sec1,sec2,md1,md2,hou1)beginif clkevent and clk=1 thenif (hou1=0010 and hou2=0011)and(min1=0101 and min2=1001) and (sec1=0101 and sec2=1001) thenhou2=0000;elsif hou2=1001and(min1=0101 and mi

7、n2=1001) and (sec1=0101 and sec2=1001) thenhou2=0000;elsif (hou2=1001and md1=0 and md2=01)or (hou1=0010and hou2=0011) thenhou2=0000;-md=1;elsif (min1=0101 and min2=1001) and (sec1=0101 and sec2=1001)or (md1=0 and md2=01) thenhou2=hou2+1;-speak=clk;end if;end if;end process h220;-分钟十位m110:process(clk

8、,min2,sec1,sec2,md1,md2)beginif clkevent and clk=1 thenif (min1=0101 and min2=1001) and (sec1=0101 and sec2=1001) then min1=0000;elsif min1=0101and min2=1001and (md1=0 and md2=00)thenmin1=0000;elsif (min2=1001and (sec1=0101 and sec2=1001) or (min2=1001and md1=0 and md2=00)thenmin1=min1+1;end if;end

9、if;-end if;end process m110;-分钟个位m220:process(clk,sec1,sec2,md1,md2)beginif clkevent and clk=1 thenif min2=1001and (sec1=0101 and sec2=1001)thenmin2=0000;elsif min2=1001and (md1=0 and md2=00)thenmin2=0000;else if (sec1=0101 and sec2=1001) or(md1=0 and md2=00)thenmin2=min2+1;end if;end if;end if;end

10、process m220;-秒十位s110:process(clk)beginif clkevent and clk=1 thenif (sec1=0101 and sec2=1001)thensec1=0000;else if sec2=1001thensec1=sec1+1;end if;end if;end if;end process s110;-秒个位s220:process(clk)beginif clkevent and clk=1 thenif sec2=1001 thensec2=0000;else sec2=sec2+1;end if;end if;end process

11、s220;-时间设置小时部分sethour1:process(clk,seth2)beginif clkevent and clk=1 thenif seth1=0010and seth2=0011 thenseth1=0000;elsif seth2=1001 thenseth1=seth1+1;end if;end if;end process sethour1;-sethour2:process(clk,md1,md2,seth1)beginif clkevent and clk=1 thenif (seth1=0010and seth2=0011)or seth2=1001thense

12、th2=0000;elsif md1=1 and md2=00 thenseth2=seth2+1;end if;end if;end process sethour2;-时间设置分钟部分setmin1:process(clk,setm2)beginif clkevent and clk=1 thenif setm1=0101and setm2=1001thensetm1=0000;elsif setm2=1001thensetm1=setm1+1;end if;end if;end process setmin1;-setmin2:process(clk,md1,md2)beginif cl

13、kevent and clk=1thenif setm2=1001thensetm2=0000;elsif md1=1 and md2=01thensetm2=setm2+1;end if;end if;end process setmin2;-闹铃speaker:process(clk1,hou1,hou2,min1,min2)beginif clk1event and clk1=1thenif seth1=hou1 and seth2=hou2 and setm1=min1 and setm2=min2 thenspeak=clk1;else speak=0;end if;end if;e

14、nd process speaker;-disp:process(sel,md1,hou1,hou2,min1,min2,sec1,sec2,seth1,seth2,setm1,setm2)beginif sel=000 thenseloutdoutdoutdoutdout=1000000;end case;elsif sel=001 thenseloutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdout=1000000;end case;elsif sel=010 thenseloutdoutdoutdoutdoutdoutdoutdout=100000

15、0;end case;elsif sel=011 thenseloutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdout=1000000;end case;elsif sel=100 thenseloutdoutdoutdoutdoutdoutdoutdout=1000000;end case;elsif sel=101 thenseloutdoutdoutdoutdoutdoutdoutdoutdoutdoutdoutdout=1000000;end case;end if;if md1=0 then-计时时间显示和设置模式h1=hou1;h2=hou2

16、;m1=min1;m2=min2;s1=sec1;s2=sec2;else -闹铃时间现实和设置模式h1=seth1;h2=seth2;m1=setm1;m2=setm2;s1=1111;s2=1111;end if;end process disp;-end one;.1数字钟的基本组成及工作原理数字钟实际上是一个对标准频率(1HZ)进行计数的计数电路.由于计数的起始时间不可能与标准时间(如北京时间)一致,故需要在电路上加一个校时电路,同时标准的1HZ时间信号必须做到准确稳定.通常使用石英晶体振荡器电路构成数字钟.图1.1所示为数字钟的一般构成框图.晶体振荡器电路晶体振荡器电路给数字钟提供一

17、个频率稳定准确的32768Hz的方波信号,可保证数字钟的走时准确及稳定.不管是指针式的电子钟还是数字显示的电子钟都使用了晶体振荡器电路.分频器电路分频器电路将32768Hz的高频方波信号经32768()次分频后得到1Hz的方波信号供秒计数器进行计数.分频器实际上也就是计数器.时间计数器电路时间计数电路由秒个位和秒十位计数器,分个位和分十位计数器及时个位和时十位计数器电路构成,其中秒个位和秒十位计数器,分个位和分十位计数器为60进制计数器,而根据设计要求,时个位和时十位计数器为12进制计数器.译码驱动电路译码驱动电路将计数器输出的8421BCD码转换为数码管需要的逻辑状态,并且为保证数码管正常工

18、作提供足够的工作电流.数码管数码管通常有发光二极管(LED)数码管和液晶(LCD)数码管,本设计提供的为LED数码管.2.2数字钟的工作原理1)晶体振荡器电路晶体振荡器是构成数字式时钟的核心,它保证了时钟的走时准确及稳定.一般输出为方波的数字式晶体振荡器电路通常有两类,一类是用TTL门电路构成;另一类是通过CMOS非门构成的电路,如图1.2所示,从图上可以看出其结构非常简单.该电路广泛使用于各种需要频率稳定及准确的数字电路,如数字钟,电子计算机,数字通信电路等.CMOS非门U1与晶体,电容和电阻构成晶体振荡器电路,U2实现整形功能,将振荡器输出的近似于正弦波的波形转换为较理想的方波.输出反馈电

19、阻为非门提供偏置,使电路工作于放大区域,即非门的功能近似于一个高增益的反相放大器.电容C1,C2与晶体构成一个谐振型网络,完成对振荡频率的控制功能,同时提供了一个180度相移,从而和非门构成一个正反馈网络,实现了振荡器的功能.由于晶体具有较高的频率稳定性及准确性,从而保证了输出频率的稳定和准确.2)分频器电路通常,数字钟的晶体振荡器输出频率较高,为了得到1Hz的秒信号输入,需要对振荡器的输出信号进行分频.通常实现分频器的电路是计数器电路,一般采用多级2进制计数器来实现.例如,将32768Hz的振荡信号分频为1HZ的分频倍数为32768(),即实现该分频功能的计数器相当于15级2进制计数器.常用

20、的2进制计数器有74HC393等.3)时间计数单元时间计数单元有时计数,分计数和秒计数等几个部分.时计数单元以24进制计数器,其输出为两位8421BCD码形式;分计数和秒计数单元为60进制计数器,其输出也为8421BCD码.一般采用10进制计数器如74HC290,74HC390等来实现时间计数单元的计数功能.欲实现24进制和60进制计数还需进行计数模值转换.4)译码驱动及显示单元计数器实现了对时间的累计以8421BCD码形式输出,为了将计数器输出的8421BCD码显示出来,需用显示译码电路将计数器的输出数码转换为数码显示器件所需要的输出逻辑和一定的电流,一般这种译码器通常称为7段译码显示驱动器

21、.常用的7段译码显示驱动器有CD4511.5)校时电源电路当重新接通电源或走时出现误差时都需要对时间进行校正.通常,校正时间的方法是:首先截断正常的计数通路,然后再进行人工出触发计数或将频率较高的方波信号加到需要校正的计数单元的输入端,校正好后,再转入正常计时状态即可library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity clock isport (clk,clr,a,c,e,f,g:in std_logic; -输入信号 led_s

22、el:out std_logic_vector( 2 downto 0); -位控输入信号 led:out std_logic_vector( 0 to 6); -七段码输出 p,q:in std_logic_vector( 3 downto 0); -选择 b:in std_logic_vector(2 downto 0); ring:out std_logic ); -蜂鸣器输出end entity clock;architecture beha of clock is signal m: integer range 0 to 999; signal hou1,hou0,min1,min0,sec1,sec0,s2: std_logic_vector(3 downto 0); signal rhou1,rhou0,rmin1,rmin0,rsec1,rsec0: std_

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1