数电实验——多功能数字钟

合集下载

数字电子技术课程设计--多功能数字钟

数字电子技术课程设计--多功能数字钟

目录第一章设计任务 (4)1.1 设计题目及要求 (4)1.1.1 题目 (4)1.1.2 设计要求 (4)第二章方案设计 (5)2.1 总体方案说明 (5)2.2 模块结构以及总体方框图 (5)第三章单元电路设计与原理说明 (6)3.1 按键消抖电路的设计 (6)3.1.1 RS触发器消抖 (6)3.2 分频器的设计 (7)3.2.2 1000分频器 (7)3.3基础电子钟及其显示设计 (8)3.3.1 时钟计数器 (8)3.3.2 功能选择及校准 (9)3.4整点报时器的设计 (10)3.5数码管显示切换电路的设计 (11)3.6 闹钟及其显示的设计 (12)第四章整机电路图及说明 .............................................................. 错误!未定义书签。

4.1整体电路图及说明................................................................................ 错误!未定义书签。

第五章电路仿真 (15)5.1基本时钟电路及其时间设置功能仿真 ................................................ 错误!未定义书签。

5.1.1基本计时功能的仿真............................................................. 错误!未定义书签。

5.1.2时间设置功能的仿真............................................................. 错误!未定义书签。

5.2整点报时功能的仿真............................................................................ 错误!未定义书签。

数电课设-数字钟

数电课设-数字钟

数字钟一.基本功能1、设计一个数字钟,能够显示当前时间,分别用6个数码管显示小时、分钟、秒钟的时间,秒针的计数频率为1Hz,可由系统脉冲分频得到。

2、在整点进行提示,可通过LED闪烁实现,闪烁频率及花型可自己设计。

3、能够调整小时和分钟的时间,调整的形式为通过按键进行累加。

4、具有闹钟功能,闹钟时间可以任意设定(设定的形式同样为通过按键累加),并且在设定的时间能够进行提示,提示同样可以由LED闪烁实现。

二.扩展功能1、设计模式选择计数器,通过计数器来控制各个功能之间转换。

2、调整当前时间以及闹钟时间,在按键累加的功能不变的基础上,增加一个功能,即当按住累加键超过3秒,时间能够以4Hz的频率累加。

3、用LCD液晶屏来显示当前时间及功能模式。

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity clock isport(clk: in std_logic; --27M晶振key3,key2,key0: in std_logic:='1'; --时、分、模式按钮,下降沿触发ledg: o ut std_logic_vector(2 downto 0):="000"; --整点提示ledr: out std_logic_vector(2 downto 0):="000"; --闹铃hex7,hex6,hex5,hex4,hex3,hex2,hex0,hex1: out std_logic_vector(6 downto 0) --数码管显示);end;architecture a of clock issignal x: integer range 1 to 13500000:=1; --记27M的上升沿个数signal clka: std_logic; --1HZsignal temp1,temp2,temp3,temp4,temp5,temp6: std_logic_vector(3 downto 0):="0000"; --时分秒走时signal xianshi1,xianshi2,xianshi3,xianshi4,xianshi5,xianshi6:std_logic_vector(3 downto 0):="0000"; --数码管显示signal temp0: std_logic_vector(1 downto 0):="00"; --模式显示signal tfen1,tfen2,tshi1,tshi2,nfen1,nfen2,nshi1,nshi2: std_logic_vector(3 downto 0); --调时和闹铃时的分、时的个位和十位signal naoling1,naoling2,naoling3,naoling4: std_logic_vector(3 downto 0); --闹铃调时时的显示begin--分频,产生1HZ的时钟process(clk)beginif clk'event and clk='1' thenx<=x+1;if x=13500000 thenclka<=not clka; --27M每13500000个上升沿clka取反x<=1;end if;end if;end process;--模式选择器,用按键控制,有0、1、2 三种模式process(key0)beginif key0'event and key0='0' thenif temp0="10" then --模式2时,再按键则进入模式0temp0<="00";elsetemp0<=temp0+1;end if;end if;end process;--模式用数码管显示process(temp0)begincase temp0 iswhen "00" => hex0<="1000000";--显示0when "01" => hex0<="1111001";--显示1when "10" => hex0<="0100100";--显示2when others => hex0<="0000000";--显示全亮end case;end process;--模式1时,调时,调节时钟的分process(key2,temp0)beginif temp0="01" thenif key2'event and key2='0' thenif tfen1="1001" then --个位到9,十位加1if tfen2="0101" then --加到59,则归零tfen1<="0000";tfen2<="0000";elsetfen2<=tfen2+1;tfen1<="0000";end if;elsetfen1<=tfen1+1;end if;end if;end if;end process;--模式1时,调时,调节时钟的时process(key3,temp0)beginif temp0="01" thenif key3'event and key3='0' thenif tshi1="1001" then ----个位到9,十位加1tshi1<="0000";tshi2<=tshi2+1;elsif tshi1="0011" and tshi2="0010" then --到23,则归零tshi1<="0000";tshi2<="0000";elsetshi1<=tshi1+1;end if;end if;end if;end process;--模式2时,设定闹铃,设定时钟的分process(key2,temp0)beginif temp0="10" thenif key2'event and key2='0' thenif nfen1="1001" then ----个位到9,十位加1if nfen2="0101" then --加到59,则归零nfen1<="0000";nfen2<="0000";elsenfen2<=nfen2+1;nfen1<="0000";end if;elsenfen1<=nfen1+1;end if;end if;end if;end process;--模式2时,设定闹铃,设定时钟的时process(key3,temp0)beginif temp0="10" thenif key3'event and key3='0' thenif nshi1="1001" then ----个位到9,十位加1nshi1<="0000";nshi2<=nshi2+1;elsif nshi1="0011" and nshi2="0010" then --到23,则归零nshi1<="0000";nshi2<="0000";elsenshi1<=nshi1+1;end if;end if;end if;end process;--三种模式间的显示及传递process(clka,temp0)beginif temp0="01" then --模式1时,传递调时的时,分temp3<=tfen1;temp4<=tfen2;temp5<=tshi1;temp6<=tshi2;xianshi3<=temp3; --模式1时,显示时,分xianshi4<=temp4;xianshi5<=temp5;xianshi6<=temp6;elsif temp0="10" then --模式2时,传递闹铃的时,分naoling1<=nfen1;naoling2<=nfen2;naoling3<=nshi1;naoling4<=nshi2;xianshi3<=naoling1; --模式2时,显示闹铃的时,分xianshi4<=naoling2;xianshi5<=naoling3;xianshi6<=naoling4;elsifclka'event and clka='1' then --正常走时,即temp0=00if temp1="1001" then --秒的个位到9,十位加1if temp2="0101" then --秒到59,则归零,分的个位加1temp1<="0000";temp2<="0000";temp3<=temp3+1;if temp3="1001" then --分的个位到9,十位加1if temp4="0101" then --分到59,则归零,时的个位加1temp3<="0000";temp4<="0000";temp5<=temp5+1;if temp5="1001" then --时的个位到9,十位加1temp5<="0000";temp6<=temp6+1;elsif temp5="0011" and temp6="0010" then --时到23,则归零temp5<="0000";temp6<="0000";end if;elsetemp3<="0000";temp4<=temp4+1;end if;elsetemp3<=temp3+1;end if;elsetemp1<="0000";temp2<=temp2+1;end if;elsetemp1<=temp1+1;end if;----到设置的闹铃时则ledr(0--2)三个灯亮,一分钟后熄灭if temp3=naoling1 and temp4=naoling2 and temp5=naoling3 and temp6=naoling4 thenledr<="111";elseledr<="000";end if;----到整点时时则ledg(0--2)三个灯亮,一分钟后熄灭if temp3="0000" and temp4="0000" thenledg<="111";elseledg<="000";end if;--将走时传递给显示译码xianshi1<=temp1;xianshi2<=temp2;xianshi3<=temp3;xianshi4<=temp4;xianshi5<=temp5;xianshi6<=temp6;end if;end process;----数码管显示译码process(xianshi1,xianshi2,xianshi3,xianshi4,xianshi5,xianshi6) begincase xianshi1 iswhen "0000" => hex2<="1000000";when "0001" => hex2<="1111001";when "0010" => hex2<="0100100";when "0011" => hex2<="0110000";when "0100" => hex2<="0011001";when "0101" => hex2<="0010010";when "0110" => hex2<="0000010";when "0111" => hex2<="1111000";when "1000" => hex2<="0000000";when "1001" => hex2<="0010000";when others => hex2<="1000000";end case;case xianshi2 iswhen "0000" => hex3<="1000000";when "0001" => hex3<="1111001";when "0010" => hex3<="0100100";when "0011" => hex3<="0110000";when "0100" => hex3<="0011001";when "0101" => hex3<="0010010";when others => hex3<="1000000";end case;case xianshi3 iswhen "0000" => hex4<="1000000";when "0001" => hex4<="1111001";when "0010" => hex4<="0100100";when "0011" => hex4<="0110000";when "0100" => hex4<="0011001";when "0101" => hex4<="0010010";when "0110" => hex4<="0000010";when "0111" => hex4<="1111000";when "1000" => hex4<="0000000";when "1001" => hex4<="0010000";when others => hex4<="1000000";end case;case xianshi4 iswhen "0000" => hex5<="1000000";when "0001" => hex5<="1111001";when "0010" => hex5<="0100100";when "0011" => hex5<="0110000";when "0100" => hex5<="0011001";when "0101" => hex5<="0010010";when others => hex5<="1000000";end case;case xianshi5 iswhen "0000" => hex6<="1000000";when "0001" => hex6<="1111001";when "0010" => hex6<="0100100";when "0011" => hex6<="0110000";when "0100" => hex6<="0011001";when "0101" => hex6<="0010010";when "0110" => hex6<="0000010";when "0111" => hex6<="1111000";when "1000" => hex6<="0000000";when "1001" => hex6<="0010000";when others => hex6<="1000000";end case;case xianshi6 iswhen "0000" => hex7<="1000000";when "0001" => hex7<="1111001";when "0010" => hex7<="0100100";when others => hex7<="1000000";end case;hex1<="1111111"; ---关闭hex1数码管end process;end;。

多功能数字钟数电课程设计实验报告

多功能数字钟数电课程设计实验报告

(数电课程设计)实验报告(理工类)2021 至2021 学年度第二学期课程名称多功能数字钟电路设计系别班级电气系11级电子信息工程一班指导教师周旭胜学号姓名耿王鑫1一、谷和伟12贺焕13、黄兴荣14解军1五、井波16李丰17、李小飞18梁富慧19目录一、设计要求及任务 ...................................................................................... 错误!未定义书签。

二、系统设计方案 ........................................................................................ 错误!未定义书签。

三、器件选择 ................................................................................................ 错误!未定义书签。

1、74LS160............................................................................................... 错误!未定义书签。

2、74LS107............................................................................................... 错误!未定义书签。

3、74LS90................................................................................................. 错误!未定义书签。

显示屏....................................................................................................... 错误!未定义书签。

多功能数字钟电路设计实验报告

多功能数字钟电路设计实验报告

多功能数字钟电路设计实验报告实验目的:设计一个多功能数字钟电路,能够显示当前时间,并具备闹钟、秒表和计时等功能。

实验原理:1. 数码管显示:使用4位共阴极数码管进行显示,采用BCD码方式输入。

2. 按键输入:使用按键进行时间的调节和选择功能。

3. 时钟频率:使用晶体振荡器提供系统时钟,通过分频电路控制时钟频率。

实验器材:1. 4位共阴极数码管2. 按键开关3. 74LS90分频器4. 时钟晶体振荡器5. 耐压电容、电阻等元件6. 电路连接线实验步骤:1. 连接电路:根据电路原理图,将数码管、按键开关、74LS90分频器、晶体振荡器等连接起来,注意接线正确。

2. 编写程序:根据实验要求,编写相应的程序,实现时钟、闹钟、秒表和计时等功能。

3. 调试电路:将电路通电并运行程序,观察数码管的显示情况和按键功能是否正常。

4. 测试功能:分别测试多功能数字钟的时钟、闹钟、秒表和计时等功能,确保功能正常。

5. 完善实验报告:根据实验结果和观察情况,完善实验报告,并附上电路原理图、程序代码等。

实验结果:经过调试和测试,多功能数字钟电路能够正常显示时间,并具备时钟、闹钟、秒表和计时功能。

使用按键进行时间调节和功能选择,数码管根据不同功能进行相应的显示。

实验总结:通过本次实验,我掌握了多功能数字钟电路的设计原理和实现方法,并且了解了数码管显示、按键输入、时钟频率控制等相关知识。

实验过程中,我发现电路连接正确性对功能实现起到关键作用,同时合理编写程序也是确保功能正常的重要环节。

通过实验,我对数字电路的设计和实现有了一定的了解,并且培养了动手实践和解决问题的能力。

多功能数字闹钟电路设计实验报告

多功能数字闹钟电路设计实验报告

多功能数字闹钟电路设计实验报告
实验目的:设计一个多功能数字闹钟电路,能够显示时间、设定并响起闹铃。

实验原理:本实验采用数字集成电路实现数字显示和闹铃功能。

数字显示部分采用BCD到七段数码管解码器74LS47和共阴
七段数码管进行实现,闹铃部分采用555定时器集成电路作为发生器,通过驱动蜂鸣器发出声音。

实验仪器:多功能数字闹钟电路实验箱、数字集成电路
74LS47、七段数码管、555定时器集成电路、蜂鸣器、电源、
示波器等。

实验步骤:
1. 按照电路图连接电路。

将74LS47连接到七段数码管,将
555定时器连接到蜂鸣器和电路中相应的电源和地线。

2. 上电并调节电路供电电压。

3. 设定时间。

通过拨动开关和按钮进行时间的设定。

4. 切换闹钟状态。

通过开关切换闹钟的开启和关闭状态。

5. 监测闹钟时间。

借助示波器调整闹钟时间的精度。

6. 监测闹钟声音。

确认蜂鸣器发出的声音符合要求。

实验结果:实验中,我们成功设计并调试出了一个多功能数字闹钟电路。

通过拨动开关和按钮可以设定时间,并且可以通过切换开关来设置闹钟的开启和关闭状态。

实验中监测到的闹钟时间和声音都符合预期要求。

结论:通过本次实验,我们成功设计了一个多功能数字闹钟电路,实现了时间显示和闹铃功能。

实验结果显示该电路的性能良好,具有实用价值。

在实验中我们也学到了关于数字集成电路和定时器集成电路的使用和调试方法。

(数电)多功能数字钟—设计报告

(数电)多功能数字钟—设计报告

1、设计内容及要求:①基本功能:以数字形式显示时、分、秒的时间,小时计数器的计时要求为24进制,并要求手动快校时、校分。

②扩展功能:整点报时。

2、系统设计原理:系统要求:数字电子钟由555集成芯片构成的振荡电路、计数器、译码器、显示器和校时电路组成。

555集成芯片构成的振荡电路产生的信号作为秒脉冲,秒脉冲送入计数器,计数结果通过“时”、“分”、“秒”译码器显示时间。

在功能方面,对于本次综合设计,还要求有校时与整点报时功能。

方案设计:图1. 数字钟电路框图电子钟的计时周期为24小时,显示满刻度为23时59分59秒,另外应有校时功能和报时功能。

因此,一个基本的数字钟电路主要由译码显示器、“时”,“分”,“秒”计数器、校时电路、报时电路和振荡器组成。

主电路系统由秒信号发生器、“时、分、秒”计数器、译码器及显示器、校时电路、整点报时电路组成。

系统工作原理:秒信号产生器是整个系统的时基信号,它直接决定计时系统的精度,用555振荡器来实现。

将标准秒信号送入“秒计数器”,“秒计数器”采用60进制计数器,每累计60秒发出一个“分脉冲”信号,该信号将作为“分计数器”的时钟脉冲。

“分计数器”也采用60进制计数器,每累计60分钟,发出一个“时脉冲”信号,该信号将被送到“时计数器”。

“时计数器”采用24进制计时器,可实现对一天24小时的累计。

译码显示电路将“时”、“分”、“秒”计数器的输出状态用七段显示译码器译码,通过七段显示器显示出来。

校时电路时用来对“时”、“分”显示数字进行校对调整。

3.单元电路的设计:3.1、基于555电路的秒脉冲发生器的设计3.1.1用555芯片设计一个多谐振荡器,输出方波用作计数器。

脉冲频率公式:f=1/(R1+2R2)C㏑2选择R1=1K,R2=5K,RV1=2K,C=100nF,形成电路图如图所示:图2. 555振荡器电路图仿真波形如图所示图3. 555脉冲仿真波形图555振荡器输出f=1000HZ,通过分频得出1HZ的脉冲,此脉冲当做秒时针脉冲。

数电实验——多功能数字钟

数电实验——多功能数字钟

大连理工大学本科实验报告题目:多功能数字钟课程名称:《数字电路课程设计》学院(系):电子信息与电气工程学部专业:自动化班级:电自0801学生姓名:学号:200881142完成日期:2011年7月20日成绩:2011 年7 月20 日题目:多功能数字钟1 设计要求(1)一个具有“时”,“分”,“秒”的十进制数字显示(小时从00~23)计时器。

(2)具有手动校时,校分的功能。

(3)定时与闹钟功能,能在设定的时间发出闹铃声(4)能整点报时。

要求从59分54秒起报时,每隔2秒发出低音,,连续3次,在整点要求是高音。

2 设计分析及系统方案设计系统总体结果系统设计要求说明:(1)该秒表用模24、模60计数器实现24小时计时(2)在调节闹钟时不影响数字钟的正常走表;(3)在调节闹钟时要通过数码管显示出;3系统以及模块硬件电路设计根据上述给出的系统总体结构框图,给出系统硬件电路设计,并作必要的说明和理论计算。

由于“数字电路课程设计”课程采用实验箱完成,没有学时涉及有关FPGA芯片的使用,因此有关FPGA芯片的部分可以用“FPGA最小系统”模块框代替。

其余接口部分(按键,LED以及数码管,各种接口等需要设计电路以及参数)。

下载时选择的开发系统模式以及管脚定义表1 GW48-CK开发系统工作模式:模式0接口名称类型(输入/输出)结构图上的信号名引脚号说明en 输入PIO7 16 手动校时(1-调时,0-走表)th 输入PIO6 11 调时按键(en=1,或en1=1调时)en1 输入PIO5 10 闹钟设定(1-调时,0-不走)tm 输入PIO4 9 调分按键(en=1或en1=1,才可调分)alarmstop 输入PIO3 8 闹铃控制端clk 输入CLOCK1 42 系统走表时钟(f=1Hz)clk1 输入CLOCK0 2 闹钟与整点报时时钟(f=256Hz)clk2 输入CLOCK5 83 整点报时时钟时钟(f=1024Hz)qhh 输出PIO47-PIO44 79、78、73、72 输出小时的高位qlh 输出PIO43-PIO40 71、70、67、66 输出小时的低位qhm 输出PIO39-PIO36 65、64、62、61 输出分钟的高位qlm 输出PIO35-PIO32 60、59、58、54 输出分钟的低位qhs 输出PIO31-PIO28 53、52、51、50 输出秒的高位qls 输出PIO27-PIO24 49、48、47、39 输出秒的低位speaker 输出SPEAKER 3 输出蜂鸣器的时钟4 系统的VHDL设计系统的各个部分如何用VHDL设计出来的应该有说明,包括论述以及真值表或者状态图等。

电工电子综合实验多功能数字时钟

电工电子综合实验多功能数字时钟

电工电子综合实验多功能数字时钟设计报告目录1、引言 (3)2、实验设计内容及要求 (4)3、设计电路的用途及原理简介 (5)4、单元电路设计原理 (5)5、电路的调试说明 (8)6、所遇到的问题及解决 (9)7、实验总结和体会 (9)8、附录(集成芯片引脚图和功能表) (10)一、引言(一)摘要:随着人类科技文明的发展,人们对于时钟的要求在不断地提高。

时钟已不仅仅被看成一种用来显示时间的工具,在很多实际应用中它还需要能够实现更多其它的功能。

高精度、多功能、小体积、低功耗,是现代时钟发展的趋势。

在这种趋势下,时钟的数字化、多功能化已经成为现代时钟生产研究的主导设计方向。

本实验要求设计一个数字计时器,可以完成0分00秒~9分59秒的计时功能,并在控制电路的作用下有开机清零、快速校分、整点报时功能。

(二)关键字:电子时钟开机清零较分整点报时(A) Abstract:With the development of technological society, people demand the clock continues to improve. The clock has not only seen as a tool used to display the time, in many practical applications, it needs to be able to achieve more other features. High-precision, multifunction, small size, low power consumption, the development trend of the modern clock. In this trend, the clock's digital, multi-functional clock production research has become a modern leading design direction.In this study, to design a digital timer, you can complete the 0 minutes 00 seconds to 9 minutes and 59 seconds chronograph function and role in the control circuit is cleared under the boot, rapid school hours, the whole point timekeeping function.(B) Keywords:Electronic Clock boot cleared the whole point timekeeping compared with sub -二、实验设计内容及要求1、设计内容简介:要求设计一个数字计时器,可以完成0分00秒~9分59秒的计时功能,并在控制电路的作用下有开机清零、快速校分、整点报时功能。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

大连理工大学本科实验报告题目:多功能数字钟课程名称:《数字电路课程设计》学院(系):电子信息与电气工程学部专业:自动化班级:电自0801学生姓名:学号:200881142完成日期:2011年7月20日成绩:2011 年7 月20 日题目:多功能数字钟1 设计要求(1)一个具有“时”,“分”,“秒”的十进制数字显示(小时从00~23)计时器。

(2)具有手动校时,校分的功能。

(3)定时与闹钟功能,能在设定的时间发出闹铃声(4)能整点报时。

要求从59分54秒起报时,每隔2秒发出低音,,连续3次,在整点要求是高音。

2 设计分析及系统方案设计系统总体结果系统设计要求说明:(1)该秒表用模24、模60计数器实现24小时计时(2)在调节闹钟时不影响数字钟的正常走表;(3)在调节闹钟时要通过数码管显示出;3系统以及模块硬件电路设计根据上述给出的系统总体结构框图,给出系统硬件电路设计,并作必要的说明和理论计算。

由于“数字电路课程设计”课程采用实验箱完成,没有学时涉及有关FPGA芯片的使用,因此有关FPGA芯片的部分可以用“FPGA最小系统”模块框代替。

其余接口部分(按键,LED以及数码管,各种接口等需要设计电路以及参数)。

下载时选择的开发系统模式以及管脚定义表1 GW48-CK开发系统工作模式:模式0接口名称类型(输入/输出)结构图上的信号名引脚号说明en 输入PIO7 16 手动校时(1-调时,0-走表)th 输入PIO6 11 调时按键(en=1,或en1=1调时)en1 输入PIO5 10 闹钟设定(1-调时,0-不走)tm 输入PIO4 9 调分按键(en=1或en1=1,才可调分)alarmstop 输入PIO3 8 闹铃控制端clk 输入CLOCK1 42 系统走表时钟(f=1Hz)clk1 输入CLOCK0 2 闹钟与整点报时时钟(f=256Hz)clk2 输入CLOCK5 83 整点报时时钟时钟(f=1024Hz)qhh 输出PIO47-PIO44 79、78、73、72 输出小时的高位qlh 输出PIO43-PIO40 71、70、67、66 输出小时的低位qhm 输出PIO39-PIO36 65、64、62、61 输出分钟的高位qlm 输出PIO35-PIO32 60、59、58、54 输出分钟的低位qhs 输出PIO31-PIO28 53、52、51、50 输出秒的高位qls 输出PIO27-PIO24 49、48、47、39 输出秒的低位speaker 输出SPEAKER 3 输出蜂鸣器的时钟4 系统的VHDL设计系统的各个部分如何用VHDL设计出来的应该有说明,包括论述以及真值表或者状态图等。

要求:系统(或顶层文件)结构描述,各个模块(或子程序)的功能描述;1)用原理图实现的,需包含以下内容:(1)系统原理图(2)主要模块或符号说明;主要模块:模60计数器,模24计数器,2)用VHDL语言实现的(1) 秒计数器(模60计数器)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;port(clk: in std_logic;clk_1: out std_logic; --clk_1表进位qh,ql:out std_logic_vector(3 downto 0) –qh,ql表示十位与个位);end;architecture a of m_601 issignal qqh,qql: std_logic_vector(3 downto 0);signal tmp: std_logic;beginprocess(clk)beginif clk'event and clk='1' thenif qql=9 thenqql<="0000";qqh<="0000";tmp<='1';elseqqh<=qqh+1;end if;elseqql<=qql+1;tmp<='0';end if;end if;end process;qh<=qqh;ql<=qql;clk_1<=tmp;end;秒计数器仿真图(2)分计数器(模60计数器)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity m_60 isport(clk,en,t: in std_logic; --在en=1控制的情况下,手动t校时clk_1: out std_logic; --clk_1表进位qh,ql:out std_logic_vector(3 downto 0) –qh,ql表十位与个位);end;architecture a of m_60 issignal qqh,qql: std_logic_vector(3 downto 0);signal tmp,tmp_1: std_logic;beginprocess(tmp_1)beginif tmp_1'event and tmp_1='1' thenif qql=9 thenqql<="0000";if qqh=5 thenqqh<="0000";tmp<='1';elseend if;elseqql<=qql+1;tmp<='0';end if;end if;end process;qh<=qqh;ql<=qql;clk_1<=tmp;process(en,clk,t)beginif en='0' thentmp_1<=clk;elsetmp_1<=t;end if;end process;end;分计数器仿真图(3)小时计数器(模24计数器)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity m_24 isport(clk,en,t: in std_logic; --在en=1控制的情况下,手动t校时qh,ql:out std_logic_vector(3 downto 0)—qh,ql表十位与个位);end;architecture a of m_24 issignal tmp: std_logic;signal qqh,qql: std_logic_vector(3 downto 0);beginprocess(en,tmp,t)beginif en='0' thentmp<=clk;tmp<=t;end if;end process;process(tmp)beginif tmp'event and tmp='1' thenif qql=9 or(qql=4 and qqh=2) thenqql<="0000";if qqh=2 thenqqh<="0000";elseqqh<=qqh+1;end if;elseqql<=qql+1;end if;end if;end process;qh<=qqh;ql<=qql;end;小时计数器(模24计数器)仿真图(4)闹钟分钟计数器(模60计数器)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity m_60b isport(clk,en: in std_logic; --在en=1是,手动给clk,闹钟加1;qh,ql:out std_logic_vector(3 downto 0));end;architecture a of m_60b issignal qqh,qql: std_logic_vector(3 downto 0);beginprocess(en,clk)beginif clk'event and clk='1' thenif en='1' thenif qql=9 thenqql<="0000";if qqh=5 thenqqh<="0000";elseqqh<=qqh+1;end if;elseqql<=qql+1;end if;end if;end if;end process;qh<=qqh;ql<=qql;end;闹钟分钟计数器(模60计数器)仿真图(5)闹钟小时计数器(模24计数器)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity m_24b isport(clk,en: in std_logic;qh,ql:out std_logic_vector(3 downto 0));end;architecture a of m_24b issignal qqh,qql: std_logic_vector(3 downto 0); beginprocess(clk,en)beginif clk'event and clk='1' thenif en='1' thenif qql=9 or(qql=4 and qqh=2) thenqql<="0000";if qqh=2 thenqqh<="0000";elseqqh<=qqh+1;end if;elseqql<=qql+1;end if;end if;end if;end process;qh<=qqh;ql<=qql;end;闹钟小时计数器(模24计数器)仿真图(6)整个系统程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;-------分钟模60计数器-------entity m_60 isport(clk,en,t: in std_logic;clk_1: out std_logic;qh,ql:out std_logic_vector(3 downto 0));end;architecture a of m_60 issignal qqh,qql: std_logic_vector(3 downto 0);signal tmp,tmp_1: std_logic;beginprocess(tmp_1)beginif tmp_1'event and tmp_1='1' thenif qql=9 thenqql<="0000";if qqh=5 thenqqh<="0000";tmp<='1';elseqqh<=qqh+1;end if;elseqql<=qql+1;tmp<='0';end if;end if;end process;qh<=qqh;ql<=qql;clk_1<=tmp;process(en,clk,t)beginif en='0' thentmp_1<=clk;elsetmp_1<=t;end if;end process;end;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;----------校分模60计数器---------entity m_60b isport(clk,en: in std_logic;qh,ql:out std_logic_vector(3 downto 0));end;architecture a of m_60b issignal qqh,qql: std_logic_vector(3 downto 0); beginprocess(en,clk)beginif clk'event and clk='1' thenif en='1' thenif qql=9 thenqql<="0000";if qqh=5 thenqqh<="0000";elseqqh<=qqh+1;end if;elseqql<=qql+1;end if;end if;end if;end process;qh<=qqh;ql<=qql;end;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;-------秒表模60计数器-----entity m_601 isport(clk: in std_logic;clk_1: out std_logic;qh,ql:out std_logic_vector(3 downto 0));end;architecture a of m_601 issignal qqh,qql: std_logic_vector(3 downto 0); signal tmp: std_logic;beginprocess(clk)beginif clk'event and clk='1' thenif qql=9 thenqql<="0000";if qqh=5 thenqqh<="0000";tmp<='1';elseqqh<=qqh+1;end if;elseqql<=qql+1;tmp<='0';end if;end if;end process;qh<=qqh;ql<=qql;clk_1<=tmp;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;------校时模24计数器------entity m_24b isport(clk,en: in std_logic;qh,ql:out std_logic_vector(3 downto 0));end;architecture a of m_24b issignal qqh,qql: std_logic_vector(3 downto 0); beginprocess(clk,en)beginif clk'event and clk='1' thenif en='1' thenif qql=9 or(qql=4 and qqh=2) thenqql<="0000";if qqh=2 thenqqh<="0000";elseqqh<=qqh+1;end if;elseqql<=qql+1;end if;end if;end if;end process;qh<=qqh;ql<=qql;end;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;------小时模24计数器------entity m_24 isport(clk,en,t: in std_logic;qh,ql:out std_logic_vector(3 downto 0)end;architecture a of m_24 issignal tmp: std_logic;signal qqh,qql: std_logic_vector(3 downto 0);beginprocess(en,tmp,t)beginif en='0' thentmp<=clk;elsetmp<=t;end if;end process;process(tmp)beginif tmp'event and tmp='1' thenif qql=9 or(qql=4 and qqh=2) thenqql<="0000";if qqh=2 thenqqh<="0000";elseqqh<=qqh+1;end if;elseqql<=qql+1;end if;end if;end process;qh<=qqh;ql<=qql;end;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity top4 isport(clk,clk1,clk2,en,en1,th,tm,alarmstop:in std_logic;--clk:系统走表时钟(f=1Hz);clk1:闹钟与整点报时时钟(f=256Hz);clk2: 整点报时时钟(f=1024Hz);en.en1:分别是校时、校分与调闹铃的使能端;th,tm:是手动调节小时与分钟的时钟--------qls,qhs,qlm,qhm,qlh,qhh: out std_logic_vector(3 downto 0);--分别表示秒低高位,分高低位,时高低位--speaker:out std_logic );speaker:是喇叭end;architecture a of top4 iscomponent m_60port(clk,en,t: in std_logic;clk_1: out std_logic;qh,ql:out std_logic_vector(3 downto 0));end component;component m_601port(clk: in std_logic;clk_1: out std_logic;qh,ql:out std_logic_vector(3 downto 0));end component;component m_60bport(clk,en: in std_logic;qh,ql:out std_logic_vector(3 downto 0));end component;component m_24port(clk,en,t: in std_logic;qh,ql:out std_logic_vector(3 downto 0));end component;component m_24bport(clk,en: in std_logic;qh,ql:out std_logic_vector(3 downto 0));end component;signal fulls,fullm:std_logic; ---秒、分进位---signal:qhhtmp,qlhtmp,qhmtmp,qlmtmp,qhhaltmp,qlhaltmp,qhmaltmp, qlmaltmp,qlstmp,qhstmp:std_logic_vector(3 downto 0);--秒,分,时中间信号--signal speaker1,speaker2:std_logic; --闹钟与整点报时的中间信号beginu1:m_601 port map(clk,fulls,qhstmp,qlstmp);u2:m_60 port map(fulls,en,tm,fullm,qhmtmp,qlmtmp);u3:m_24 port map(fullm,en,th,qhhtmp,qlhtmp);u4:m_24b port map(th,en1,qhhaltmp,qlhaltmp);u5:m_60b port map(tm,en1,qhmaltmp,qlmaltmp);process(en1,qhhaltmp,qlhaltmp,qhmaltmp,qlmaltmp,qhhtmp,qlhtmp,qhmtmp,qlmtmp)beginif en1='1' then----在闹钟调节时,把闹钟显示的界面显示出来并且不影响时钟的正常走表----qhh<=qhhaltmp;qlh<=qlhaltmp;qhm<=qhmaltmp;qlm<=qlmaltmp;qhs<="0000";qls<="0000";else ---在en=0时显示正常走表---qhs<=qhstmp;qls<=qlstmp;qhh<=qhhtmp;qlh<=qlhtmp;qhm<=qhmtmp;qlm<=qlmtmp;end if;end process;----------闹钟---------process(alarmstop,qhhaltmp,qlhaltmp,qhmaltmp,qlmaltmp,qhhtmp,qlhtmpqhmtmp,qlmtmp),----当到预设时间时别且alarmstop=0是每隔2秒响一次----beginif qhhaltmp=qhhtmp and qlhaltmp=qlhtmp and qhmaltmp=qhmtmp andqlmaltmp=qlmtmpand (qlstmp=1 or qlstmp=3 or qlstmp=5 or qlstmp=7 or qlstmp=9)thenif alarmstop='0' thenspeaker2<=clk1;elsespeaker2<='0';end if;elsespeaker2<='0';end if;end process;------整点报时,每隔2秒响一次并且在整点时是高音-----process(en,qhmtmp,qlmtmp,qhstmp,qlstmp,clk1,clk2,clk)beginif en='0' and en1='0' thenif (qhmtmp=5 and qlmtmp=9) thenif clk='1' thenif (qhstmp=5 and qlstmp=4) or (qhstmp=5 and qlstmp=6)or (qhstmp=5 and qlstmp=8) thenspeaker1<=clk1;----响三下并且是低音----else speaker1<='0';end if;else speaker1<='0';end if;elsif (qhmtmp=0 and qlmtmp=0) thenif (qhstmp=0 and qlstmp=0) then------在整点时是高音----speaker1<=clk2;else speaker1<='0';end if;else speaker1<='0';end if;end if;end process;-------将闹钟或整点报时的信号都赋给蜂鸣器speaker--- speaker<=speaker1 or speaker2;end;整个系统仿真图:图1分针与时针的进位,整点报时图2 调节并显示闹钟时间图3 闹钟功能的实现图4 闹钟的暂停图5 手动校时,校分5 结论以及结果说明软件平台:MAX+PLUS2硬件平台:FPDA芯片:FLEX10K EPF10K10LC84-4工作模式:方式0实验结果说明:(1)在en=’0’且en1=’0’时,数字钟正常走表。

相关文档
最新文档