




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、摘 要 人类社会已进入到高度发达的信息社会。信息化社会的发展离不开电子信息产品开发技术、产品品质的提高和进步。电子信息产品随着科学技术的进步,其电子器件和设计方法更新换代的速度日新月异。实现这种进步的主要原因就是电子设计技术和电子制造技术的发展,其核心就是电子设计自动化(EDA,ElectronicsDesignAutomation)技术,EDA技术的发展和推广应用又极大地推动了电子信息产业的发展。为保证电子系统设计的速度和质量,适应“第一时间推出产品”的设计要求,EDA技术正逐渐成为不可缺少的一项先进技术和重要工具。目前,在国内电子技术教学和产业界的技术推广中已形成“EDA热”,完全可以说,
2、掌握EDA技术是电子信息类专业学生、工程技术人员所必备的基本能力和技能。关键词:数字钟 EDA VHDL语言数字时钟的设计实现设计实验一、设计目的1、熟练地运用数字系统的设计方法进行数字系统设计;2、能进行较复杂的数字系统设计;3、按要求设计一个数字钟。二、设计内容2.1设计任务及目标要求设计一个数字钟完,完成具体如下任务:(1)能显示年、月、日、时、分、秒功能;(2)具有日期和星期显示功能;(3)具备闹钟功能及定点报时;(4)具备调时、定时功能。三、系统方案及设计原理3.1方案设计数字计时器基本功能是计时,因此首先需要获得具有精确振荡时间的脉振信号,以此作为计时电路的时序基础,实验中可以使用
3、的振荡频率源为48MHZ,通过分频获得所需脉冲频率(1Hz,1KHz,2KHz)。为产生秒位,设计一个模60计数器,对1HZ的脉冲进行秒计数,产生秒位;为产生分位,通过秒位的进位产生分计数脉冲,分位也由模60计数器构成;为产生时位,用一个模24计数器对分位的进位脉冲进行计数。整个数字计时器的计数部分共包括六位:时十位、时个位、分十位、分个位、秒十位和秒个位。显示功能是通过数选器、译码器、码转换器和7段显示管实现的。因为实验中只用一个译码显示单元,7个7段码(6个用于显示时分秒,一个显示星期),所以通过4个7选一MUX和一个3-8译码器配合,根据计数器的信号进行数码管的动态显示。清零功能是通过控
4、制计数器清零端的电平高低来实现的。只需使清零开关按下时各计数器的清零端均可靠接入有效电平(本实验中是低电平),而清零开关断开时各清零端均接入无效电平即可。校分校时功能由防抖动开关、逻辑门电路实现。其基本原理是通过逻辑门电路控制分计数器的计数脉冲,当校分校时开关断开时,计数脉冲由低位计数器提供;当按下校分校时开校分校时功能由防抖动开关、逻辑门电路实现。其基本原理是通过逻辑门电路控制分计数器的计数脉冲,当校分校时开关断开时,计数脉冲由低位计数器提供;当按下校分校时开通时,既可以手动触发出发式开关给进位脉冲,也可以有恒定的1Hz脉冲提供恒定的进位信号,计数器在此脉冲驱动下可快速计数。为实现可靠调时,
5、采用防抖动开关(由D触发器实现)克服开关接通或断开过程中产生的一串脉冲式振动。本实验中为节省按键,闹钟时间调节键复用正常调时的校时校分开关,为使设定闹铃与正常计时中调节时间按键互不影响,额外用一个闹钟使能键,按下该键后进入闹钟设定界面,此时校时校分开关用于调节闹钟时间,对正常计时没有影响,且此时7段显示码显示的是闹钟时间;恢复使能键后校分校时键用于对数字钟进行时间调节,对设定的闹钟时间没有影响。整点报时功能可以通过组合逻辑电路实现。当计数器的各位呈现特定的电平时,可以选通特定的与门和或门,将指定的频率信号送入蜂鸣器中,实现在规定的时刻以指定频率发音报时。闹钟设定功能。闹钟只设定时和分,基本模块
6、与正常计时电路里的校时校分电路相同。本实验中为节省按键,闹钟时间调节键复用正常调时的校时校分开关,为使设定闹铃与正常计时中调节时间按键互不影响,额外用一个闹钟使能键,按下该键后进入闹钟设定界面,此时校时校分开关用于调节闹钟时间,对正常计时没有影响,且此时7段显示码显示的是闹钟时间;恢复使能键后校分校时键用于对数字钟进行时间调节,对设定的闹钟时间没有影响。3.2数字钟设计思路结构框图控制单元使能信号数字时钟CLK时钟信号报警(闹铃)信号复位信号输出信号LED显示扬声器四、数字电路基本模块4.1分频器模块(1)模块说明:输入一个频率为50MHz的CLK,利用计数器分出1KHz的q1KHz,500H
7、z的q500Hz,2Hz的q2Hz和1Hz的q1Hz。(2)源程序:LIBRARY ieee; USE ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;ENTITY fdiv IS PORT (CLK: IN STD_LOGIC ; -输入时钟信号 q1KHz: BUFFER STD_LOGIC; q500Hz: BUFFER STD_LOGIC; q2Hz: BUFFER STD_LOGIC; q1Hz: OUT STD_LOGIC);END fdiv ; ARCHITECTURE bhv OF fdiv IS BEGIN P
8、1KHZ:PROCESS(CLK)VARIABLE cout:INTEGER:=0;BEGIN IF CLKEVENT AND CLK=1 THEN cout:=cout+1; -每来个时钟上升沿时cout开始计数IF cout=25000 THEN q1KHz=0; -当cout=25000时,q1KHz输出“0” ELSIF cout50000 THEN q1KHz=1; -当25000cout=50000时,q1KHz ELSE cout:=0; -输出“1”,完成1KHz频率输出END IF; END IF; END PROCESS; P500HZ:PROCESS(q1KHz) -q1
9、KHz作为输入信号,分出q500HzVARIABLE cout:INTEGER:=0;BEGINIF q1KHzEVENT AND q1KHz=1 THENcout:=cout+1;IF cout=1 THEN q500Hz=0; -二分频 ELSIF cout=2 THEN cout:=0;q500Hz=1;END IF; END IF; END PROCESS;P2HZ:PROCESS(q500Hz)VARIABLE cout:INTEGER:=0;BEGINIF q500HzEVENT AND q500Hz=1 THENcout:=cout+1;IF cout=125 THEN q2Hz
10、=0; ELSIF cout250 THEN q2Hz=1; ELSE cout:=0;END IF; END IF; END PROCESS;P1HZ:PROCESS(q2Hz)VARIABLE cout:INTEGER:=0;BEGINIF q2HzEVENT AND q2Hz=1 THENcout:=cout+1;IF cout=1 THEN q1Hz=0; ELSIF cout=2 THEN cout:=0;q1Hz=1;END IF; END IF; END PROCESS;END bhv;(3)模块图:4.2控制器模块(1)模块说明:输入端口enset,k,set键来控制6个状态,
11、这六个状态分别是显示计时时间状态,调计时的时、分、秒状态,调闹铃的时、分的状态,reset键是复位键,用来回到显示计时时间的状态。(2)源程序:library ieee;use ieee.std_logic_1164.all;entity contl is port(clk,enset,k,set,reset:in std_logic; cth,ctm,cts,cbh,cbm,flashh,flashm,flashs,sel_show:out std_logic);end contl;architecture rtl of contl is type stats is (s0,s1,s2,s3
12、,s4,s5); -定义6个状态 signal current_state,next_state:stats:=s0;begin process(clk,reset) begin if reset=1 then current_state=s0; elsif clkevent and clk=1 then if reset=0 then current_statecth=0;ctm=0;cts=0;cbh=0;cbm=0; flashh=0;flashm=0;flashs=0;sel_show=0; if (enset=1 and k=1)then -若enset和k为“1”, next_st
13、ate=s1; -由s0态转到s1态 else next_statectm=0;cts=0;cbh=0;cbm=0; flashh=1;flashm=0;flashs=0;sel_show=0; if set=1 then cth=1; -若set为“1”,cth输出“1” else cth=0; -进入调小时状态。 end if; if (enset=1 and k=0)then -若enest为“1”,k为“0”, next_state=s2; -由s1态转到s2态 else next_statecth=0;cts=0;cbh=0;cbm=0; flashh=0;flashm=1;flas
14、hs=0;sel_show=0; if set=1 then ctm=1; else ctm=0; end if; if(enset=1 and k=1)then next_state=s3; else next_statecth=0;ctm=0;cbh=0;cbm=0; flashh=0;flashm=0;flashs=1;sel_show=0; if set=1 then cts=1; else cts=0; end if; if (enset=1 and k=0)then next_state=s4; else next_statecth=0;ctm=0;cts=0;cbm=0; fla
15、shh=1;flashm=0;flashs=0;sel_show=1; if set=1 then cbh=1; else cbh=0; end if; if(enset=1 and k=1)then next_state=s5; else next_statecth=0;ctm=0;cts=0;cbh=0; flashh=0;flashm=1;flashs=0;sel_show=1; if set=1 then cbm=1; else cbm=0; end if; if(enset=1 and k=0)then next_state=s0; else next_state=s5; end i
16、f; end case; end process;end rtl;(3)仿真波形图:(4)模块图:4.3二选一模块(1)源程序:ENTITY mux21a ISPORT(a,b,s:IN BIT; y:OUT BIT);END ENTITY mux21a;ARCHITECTURE one OF mux21a ISBEGIN PROCESS(a,b,s)BEGINIF s=0 THEN y=a;ELSE -若s=0,y输出a,反之输出b。y=b;END IF;END PROCESS;END ARCHITECTURE one;(2)仿真波形图:(3)模块图:4.4计时模块4.4.1秒计时模块(1)
17、源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith;entity cnts60 is port(sld0:buffer std_logic_vector(3 downto 0); -小时个位 sld1:buffer std_logic_vector(7 downto 4); -小时十位 co: out std_logic; rest:in std_logic; clk :in std_logic);end cnts60;architecture
18、 rtl of cnts60 is begin process(clk,rest) begin if rest=1 then sld1=0000; sld0=0000; elsif (clkevent and clk=1) then if (sld1=0101and sld0=1001)then -当sld1=5,sld0=9时 sld1=0000; sld0=0000;co=1;-全清零,co输出“1” elsif sld0=1001 then sld0=0000; sld1=sld1+1;co=0; - sld1自加“1” else sld0=sld0+1;co=0; end if; en
19、d if; end process;end rtl;(2)仿真波形图:(3)模块图:4.4.2分计时(1)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith;entity cnt60 is port(sld0:buffer std_logic_vector(3 downto 0); sld1:buffer std_logic_vector(7 downto 4); co: out std_logic; clk :in std_logic);en
20、d cnt60;architecture rtl of cnt60 is begin process(clk) begin if (clkevent and clk=1) then if (sld1=0101and sld0=1001)then sld1=0000; sld0=0000;co=1; elsif sld0=1001 then sld0=0000; sld1=sld1+1;co=0; else sld0=sld0+1;co=0; end if; end if; end process;end rtl;(2)仿真波形图:(3)模块图:4.4.3小时计时(1)源程序:library i
21、eee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith;entity cnt24 is port(sld0:buffer std_logic_vector(3 downto 0); sld1:buffer std_logic_vector(7 downto 4); clk :in std_logic);end cnt24;architecture rtl of cnt24 is signal s:std_logic_vector(7 downto 0);begin proc
22、ess(clk) begin s=sld1&sld0; if (clkevent and clk=1) then if s=then sld1=0000; sld0=0000; elsif sld0=1001 then sld0=0000; sld1=sld1+1; else sld0=sld0+1; end if; end if; end process;end rtl;(2)仿真波形图:(3)模块图:4.4.4闹钟分计时(1)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ie
23、ee.std_logic_arith;entity cntm60b is port(sld0:buffer std_logic_vector(3 downto 0); sld1:buffer std_logic_vector(7 downto 4); en:in std_logic; clk :in std_logic);end cntm60b;architecture rtl of cntm60b is begin process(clk) begin if (clkevent and clk=1) then if en=1 then if (sld1=0101and sld0=1001)t
24、hen sld1=0000; sld0=0000; elsif sld0=1001 then sld0=0000; sld1=sld1+1; else sld0=sld0+1; end if; end if; end if; end process;end rtl;(2)仿真波形图:(3)模块图:4.4.5闹钟小时计时(1)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith;entity cnth24b is port(sld0:buffer
25、std_logic_vector(3 downto 0); sld1:buffer std_logic_vector(7 downto 4); en:in std_logic; clk :in std_logic);end cnth24b;architecture rtl of cnth24b is signal s:std_logic_vector(7 downto 0);begin process(clk,en,sld1,sld0) begin s=sld1&sld0; if (clkevent and clk=1) then if en=1 then if s=then sld1=000
26、0; sld0=0000; elsif sld0=1001 then sld0=0000; sld1=sld1+1; else sld0=sld0+1; end if; end if; end if; end process;end rtl;(2)仿真波形图:(3)模块图:4.5闹钟比较模块(1)模块说明:比较正常计数时间与闹钟定时时间是否相等,若相等,compout输出“1”,反之输出“0”。(2)源程序:library ieee;use ieee.std_logic_1164.all;entity comp is port(th1,tm1:in std_logic_vector(7 dow
27、nto 4); th0,tm0:in std_logic_vector(3 downto 0); bh1,bm1:in std_logic_vector(7 downto 4); bh0,bm0:in std_logic_vector(3 downto 0); compout:out std_logic);end comp;architecture rtl of comp isbegin process(th1,tm1,bh1,bm1,th0,tm0,bh0,bm0) begin if( th1=bh1 and tm1=bm1 and th0=bh0 and tm0=bm0 ) then co
28、mpout=1;-当正常计数时间与闹钟定时时间相等时compout输出1 else compout=0; end if; end process;end rtl;(3)仿真波形图:(4)模块图:4.6报时模块(1)模块说明:该模块既实现了整点报时的功能,又实现了闹铃的功能,蜂鸣器通过所选频率的不同,而发出不同的声音。(2)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity bel is port(tm1,ts1:in std_logic_vector(7 downto 4); t
29、m0,ts0:in std_logic_vector(3 downto 0); compout,q1KHz,q500Hz,openbel:in std_logic; bell:out std_logic);end bel;architecture rtl of bel is signal t:std_logic_vector(7 downto 0);begin process(compout,q500Hz,q1KHz,openbel,tm1,tm0,ts1,ts0) begin if (openbel =0 ) then bell=0; end if; if (openbel =1 ) the
30、n if (compout=1) then - compout=1,闹铃响 bellbellbellbellbellbellbell=0; end case; else bell=0; end if; end if; end process;end rtl;(3)仿真波形图:(4)模块图:4.7控制显示模块(1)模块说明:该模块实现了数码管既可以显示正常时间,又可以显示闹钟时间的功能;调时,定时闪烁功能也在此模块中真正实现。(2)源程序:library ieee;use ieee.std_logic_1164.all;entity show_con is port(th1,tm1,ts1:in
31、 std_logic_vector(7 downto 4); th0,tm0,ts0:in std_logic_vector(3 downto 0); bh1,bm1:in std_logic_vector(7 downto 4); bh0,bm0:in std_logic_vector(3 downto 0); sec1,min1,h1: out std_logic_vector(7 downto 4); sec0,min0,h0: out std_logic_vector(3 downto 0); q2Hz,flashs,flashh,flashm,sel_show:in std_logi
32、c);end show_con;architecture rtl of show_con isbegin process(th1,tm1,ts1,th0,tm0,ts0,bh1,bm1,bh0,bm0,q2Hz,flashs,flashh,flashm,sel_show) begin if sel_show=0then if ( flashh=1and q2Hz=1)then h1=1111;h0=1111; -显示小时数码管以2Hz闪烁 min1=tm1;min0=tm0; sec1=ts1;sec0=ts0; elsif (flashm=1and q2Hz=1)then h1=th1;h0
33、=th0; min1=1111;min0=1111; sec1=ts1;sec0=ts0; elsif (flashs=1and q2Hz=1)then h1=th1;h0=th0; min1=tm1;min0=tm0; sec1=1111;sec0=1111; else h1=th1;h0=th0; min1=tm1;min0=tm0; sec1=ts1;sec0=ts0; end if; elsif sel_show=1then-若sel_show为“1”,数码管显示闹钟时间 if(flashh=1 and q2Hz=1)then h1=1111;h0=1111; min1=bm1;min
34、0=bm0; sec1=0000;sec0=0000; elsif ( flashm=1 and q2Hz=1)then h1=bh1;h0=bh0; min1=1111;min0=1111; sec1=0000;sec0=0000; else h1=bh1;h0=bh0; min1=bm1;min0=bm0; sec1=0000;sec0=0000; end if ; end if; end process;end rtl;(3)模块图:4.8动态扫描显示模块(1)模块说明:由6组输入信号和7个数据输出信号和8个位选通信号来实现数码管的驱动和信号扫描,进而实现了时钟时,分,秒的动态显示。(2
35、)源程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity SCAN_LED isport(clk1:in std_logic; h0:in std_logic_vector(3 downto 0); h1:in std_logic_vector(7 downto 4); min0:in std_logic_vector(3 downto 0); min1:in std_logic_vector(7 downto 4); sec0:in std_logic_vector(3 downto 0); sec1:in std_logic_vector(7 downto 4); daout:out std_logic_vector(6 downto 0); se:out std_logic_vector(2 downto 0);end;architecture one of SCAN_LED issignal cnt6:std_logic_vector(2 downto 0);signa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年《医疗器械监督管理条例》培训试题及答案
- 2025至2030中国不动产行业市场发展分析及发展趋势与投资机会报告
- 三年级英语教学计划
- 2025至2030中国自动角膜折射计行业发展趋势分析与未来投资战略咨询研究报告
- 2025至2030中国自动注塑机行业发展趋势分析与未来投资战略咨询研究报告
- 2025至2030中国自动层压机行业市场占有率及投资前景评估规划报告
- 2025至2030中国自主水下滑翔机行业发展趋势分析与未来投资战略咨询研究报告
- 2025至2030中国腕式计算机行业产业运行态势及投资规划深度研究报告
- 石油化工设备的维护保养技术规范
- 2025至2030中国脂溢性角化病行业发展趋势分析与未来投资战略咨询研究报告
- 驻非洲员工管理制度
- 工程内业资料管理制度
- 美容院商业计划书(完整版)
- 摩托车协议过户协议书
- 2025年食品检验员考试试卷及答案
- 四川省德阳市2025年七年级下学期语文期末试卷及答案
- 黎族文化课件
- 中华人民共和国民营经济促进法
- 色彩的魅力:艺术、科学与设计的交融
- 2025广州市荔湾区辅警考试试卷真题
- 一季度安委会汇报材料
评论
0/150
提交评论