版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、vhdl设计数字钟系统1熟练利用vhdl语言进行数字系统设计; 2. 掌握数字系统的设计方法自顶向下的设计思想; 3掌握计数器的设计与使用; 4掌握调时,调分功能的实现;5根据数字钟的功能要求设计一个数字钟;6. 掌握闹钟系统的原理。 数字钟是一计时的工具,有着广泛的用途。本实验的数字钟要求有三个功能按钮:一个是清零按钮reset11,当按下此按钮时,数字钟显示有位都清零二是调分钟的按钮 setmin,当按下此按钮时分钟会以1hz的频率速度进行调时,而且在调分钟时秒钟会暂停不动;三是调小时的按钮sethour,当按下此按钮时时钟会以1hz的频率速度进行调时,在调小时时分钟会暂停不动,但秒钟是正
2、常记时的。 另外还有一个闹钟模块,在闹钟模块中,当按下调时或调分键时,数码显示管显示所调闹钟的时间,并进行调时或调分。当两个键都未按下时,数码管显示数字钟的时间。当设定的闹钟时间和数字钟的时间一致时,红灯亮,黄灯灭,同时喇叭叫。其余时间黄灯亮,红灯灭,喇叭不叫。此数字钟是以24小时制记时,当到整点时会报时一分钟,按下清零键时也会报时一分钟。主要元件有计数器,分频器,报时器,选择器和译码器等。控制逻辑主要是用来实现计数和清零。基本方框图如下:.分频模块采用原理图输入方式实现2分频与1000分频,但这里并没有用到1000分频,因为后来考虑到精度问题,将千分频用直接输入了。程序如图:利用三个7490
3、进行硬件分频!微秒模块采用vhdl语言输入方式,以时钟clk,清零信号clr以及暂停信号stop为进程敏感变量,程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity minsecondb isport(clk,clrm,stop:in std_logic;-时钟/清零信号 secm1,secm0:out std_logic_vector(3 downto 0);-秒高位/低位 co:out std_logic);-输出/进位信号end minsecondb;architectur
4、e sec of minsecondb issignal clk1,dout2:std_logic;beginprocess(clk,clrm)variable cnt1,cnt0:std_logic_vector(3 downto 0);-计数 variable count2 :integer range 0 to 10 ;beginif clkevent and clk=1then if count2=0 and count210 then count2:=count2+1; else count2:=0; dout2= not dout2; end if; end if;if clrm=
5、1 then-当clr为1时,高低位均为0cnt1:=0000;cnt0:=0000;elsif clkevent and clk=1 then if stop=1 then cnt0:=cnt0; cnt1:=cnt1; end if;if cnt1=1001 and cnt0=1000 then-当记数为98(实际是经过59个记时脉冲)co=1;-进位cnt0:=1001;-低位为9elsif cnt01001 then-小于9时cnt0:=cnt0+1;-计数-elsif cnt0=1001 then-clk1=not clk1;elsecnt0:=0000;if cnt11001 th
6、en-高位小于9时cnt1:=cnt1+1;elsecnt1:=0000;co=0;end if;end if;end if;secm1=cnt1;secm0=cnt0;end process;end sec;秒模块程序清单 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity second isport(clk,clr:in std_logic;-时钟/清零信号 sec1,sec0:out std_logic_vector(3 downto 0);-秒高位/低位 co:out std_l
7、ogic);-输出/进位信号end second;architecture sec of second isbeginprocess(clk,clr)variable cnt1,cnt0:std_logic_vector(3 downto 0);-计数beginif clr=1 then-当ckr为1时,高低位均为0cnt1:=0000;cnt0:=0000;elsif clkevent and clk=1 thenif cnt1=0101 and cnt0=1000 then-当记数为58(实际是经过59个记时脉冲)co=1;-进位cnt0:=1001;-低位为9elsif cnt01001
8、 then-小于9时cnt0:=cnt0+1;-计数elsecnt0:=0000;if cnt10101 then-高位小于5时cnt1:=cnt1+1;elsecnt1:=0000;co=0;end if;end if;end if;sec1=cnt1;sec0=cnt0;end process;end sec; 分模块程序清单 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity minute isport(clk,en:in std_logic; min1,min0:out std_
9、logic_vector(3 downto 0); co:out std_logic);end minute;architecture min of minute isbeginprocess(clk)variable cnt1,cnt0:std_logic_vector(3 downto 0);beginif clkevent and clk=1 thenif en=1 thenif cnt1=0101 and cnt0=1000 thenco=1;cnt0:=1001;elsif cnt01001 thencnt0:=cnt0+1;elsecnt0:=0000;if cnt10101 th
10、encnt1:=cnt1+1;elsecnt1:=0000;co=0;end if;end if;end if;end if;min1=cnt1;min0=cnt0;end process;end min;时模块程序清单 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour isport(clk,en:in std_logic;-输入时钟/高电平有效的使能信号 h1,h0:out std_logic_vector(3 downto 0);-时高位/低位end hour;archi
11、tecture hour_arc of hour isbeginprocess(clk)variable cnt1,cnt0:std_logic_vector(3 downto 0);-记数beginif clkevent and clk=1 then-上升沿触发if en=1 then-同时“使能”为1if cnt1=0010 and cnt0=0011 thencnt1:=0000;-高位/低位同时为0时cnt0:=0000;elsif cnt01001 then-低位小于9时,低位记数累加cnt0:=cnt0+1;elsecnt0:=0000;cnt1:=cnt1+1;-高位记数累加en
12、d if;end if;end if;h1=cnt1;h0=cnt0;end process;end hour_arc;动态扫描模块 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity seltime is port( clk:in std_logic;-扫描时钟 secm1,secm0,sec1,sec0,min1,min0,h1,h0:in std_logic_vector(3 downto 0);-分别为秒个位/时位;分个位
13、/ daout:out std_logic_vector(3 downto 0);-输出 sel:out std_logic_vector(2 downto 0);-位选信号end seltime;architecture fun of seltime is signal count:std_logic_vector(2 downto 0);-计数信号begin sel=111) then count=000; else countdaoutdaoutdaoutdaoutdaoutdaoutdaoutdaout=h1; end case; end process;end fun;报时模块 li
14、brary ieee;use ieee.std_logic_1164.all;entity alert isport(m1,m0,s1,s0:in std_logic_vector(3 downto 0);-输入秒、分高/低位信号 clk:in std_logic;-高频声控制 q500,qlk:out std_logic);-低频声控制end alert;architecture sss_arc of alert is begin process(clk) begin if clkevent and clk=1 then if m1=0101 and m0=1001 and s1=0101
15、then-当秒高位为5,低位为9时且分高位为5 if s0=0001 or s0=0011 or s0=0101 or s0=0111 then-当分的低位为1或3或5或7时 q500=1;-低频输出为1 else q500=0;-否则输出为0 end if; end if;if m1=0101 and m0=1001 and s1=0101 and s0=1001 then-当秒高位为5,低位为9时且分高位为5,-分低位为9时,也就是“59分59秒”的时候“报时” qlk=1;-高频输出为1 else qlkqqqqqqqqqq=1101111;-显示9end case; end proce
16、ss;end disp_are;顶层文件(原理图输入) * 数字钟设计模块与程序(不含秒表)* 1.分频模块(原理图输入) 2. 秒模块程序 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity second isport(clk,clr:in std_logic; sec1,sec0:out std_logic_vector(3 downto 0); co:out std_logic);end second;architecture sec of second isbeginproces
17、s(clk,clr)variable cnt1,cnt0:std_logic_vector(3 downto 0);beginif clr=1 thencnt1:=0000;cnt0:=0000;elsif clkevent and clk=1 thenif cnt1=0101 and cnt0=1000 thenco=1;cnt0:=1001;elsif cnt01001 thencnt0:=cnt0+1;elsecnt0:=0000;if cnt10101 thencnt1:=cnt1+1;elsecnt1:=0000;co=0;end if;end if;end if;sec1=cnt1
18、;sec0=cnt0;end process;end sec;3.分模块程序 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity minute isport(clk,en:in std_logic; min1,min0:out std_logic_vector(3 downto 0); co:out std_logic);end minute;architecture min of minute isbeginprocess(clk)variable cnt1,cnt0:std_logi
19、c_vector(3 downto 0);beginif clkevent and clk=1 thenif en=1 thenif cnt1=0101 and cnt0=1000 thenco=1;cnt0:=1001;elsif cnt01001 thencnt0:=cnt0+1;elsecnt0:=0000;if cnt10101 thencnt1:=cnt1+1;elsecnt1:=0000;co=0;end if;end if;end if;end if;min1=cnt1;min0=cnt0;end process;end min;4.时模块程序library ieee;use i
20、eee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour isport(clk,en:in std_logic; h1,h0:out std_logic_vector(3 downto 0);end hour;architecture hour_arc of hour isbeginprocess(clk)variable cnt1,cnt0:std_logic_vector(3 downto 0);beginif clkevent and clk=1 thenif en=1 thenif cnt1=0010 and
21、cnt0=0011 thencnt1:=0000;cnt0:=0000;elsif cnt01001 thencnt0:=cnt0+1;end if;end if;end if;h1=cnt1;h0=cnt0;end process;end hour_arc;5.扫描模块程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity seltime is port( clk:in std_logic; sec1,sec0,min1,min0,h1,h0:in std_logic_vector(3 downto 0); daout:out std_logic_vector(3 downto 0); sel:out std_logic_vector(2 downt
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 点的构成 教学课件
- 《十万个为什么》米伊林版阅读练习题1含答案
- HJ 356-2019 水污染源在线监测系统(CODCr、NH3-N等)数据有效性判别技术规范
- 尔雅2016-07-10-创新思维训练考试答案
- 1.1物质的分类及转化-高一化学人教版(2019)必修一课时优化训练
- 河北省邯郸市2023至2024学年高一下学期期末考试化学试题附参考答案(解析)
- 上海市交大二附中2025年中考适应性测试试卷(数学试题文)试题含解析
- 陕西省渭南市合阳县2025年初三中考3月模拟试卷数学试题含解析
- 浅谈色谱在线监测装置运行技术
- 慢性肾病医院项目节能评估报告模板
- 2024年新北师大版七年级上册数学课件 2.2 第5课时 有理数的加减混合运算的运用
- 2024年全国职业院校技能大赛高职组(检验检疫技术赛项)考试题库(含答案)
- 2024-2030年中国有机过氧化物市场运营态势及投资价值评估分析研究报告
- 2024年水生产处理工(中级)职业技能鉴定考试题库(含答案)
- 科室手卫生分析
- 2024年江苏徐州市教育局直属事业单位选调7人历年(高频重点复习提升训练)共500题附带答案详解
- 新课改国家《科学课程标准》(7--9年级)
- 2023船舶应用电池动力规范
- GB/T 18910.3-2024液晶显示器件第3部分:液晶显示屏分规范
- 《智慧农业关键技术与装备》课件-第10章 农业信息处理技术
- 机房设备搬迁方案(2篇)
评论
0/150
提交评论