当前位置:文档之家› 数电实验——多功能数字钟

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

大连理工大学本科实验报告题目:多功能数字钟课程名称:《数字电路课程设计》学院(系):电子信息与电气工程学部专业:自动化班级:电自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’时,数字钟正常走表。

相关主题