2022年EDA课程方案设计书多功能数字钟.docx
精品学习资源封面欢迎下载精品学习资源作者: PanHongliang仅供个人学习哈尔滨工业高校 威海 电子学课程设计报告欢迎下载精品学习资源带有整点报时的数字钟设计与制作姓名:班级:蒋栋栋0802503学号:指导老师 :080250331井岩目录一、课程设计的性质、目的和任务3二、课程设计基本要求3三、设计课题要求3四、课程设计所需要仪器4五、设计步骤41、整体设计框图42、各个模块的设计与仿真42.1 分频模块42.2 计数器模块62.3 把握模块102.4 数码管支配132.5显示模块142.6报时模块16六、调试中遇到的问题及解决的方法18七、心得体会18一、课程设计的性质、目的和任务创新精神和实践才能二者之中,实践才能是基础和根本;这是由于创新基于实践、源于实践,实践出真知,实践检验真理;实践活动是创新的源泉,也是人才成长的必由之路;通过课程设计的锤炼,要求同学把握电路的一般设计方法,具备初步的独立设欢迎下载精品学习资源计才能,提高综合运用所学的理论学问独立分析和解决问题的才能,培养同学的创新精神;二、课程设计基本要求把握现代大规模集成数字规律电路的应用设计方法,进一步把握电子仪器的正确使用方法,以及把握利用运算机进行电子设计自动化EDA 的基本方法;三、设计课题要求(1) )构造一个 24 小时制的数字钟;要求能显示时、分、秒;(2) )要求时、分、秒能各自独立的进行调整;(3) )能利用喇叭作整点报时;从59 分 50 秒时开头报时,每隔一秒报时一秒, 到达 00 分 00 秒时,整点报时;整点报时声的频率应与其它的报时声频有明显区分;#设计提示(仅供参考):(1) 对频率输入的考虑数字钟内所需的时钟频率有:基准时钟应为周期一秒的标准信号;报时频率可选用 1KHz 和 2KHz 左右 两种频率相差八度音,即频率相差一倍 ;另外, 为防止按键反跳、抖动,微动开关输入应接受寄存器输入形式,其时钟应为几十赫兹;(2) 计时部分计数器设计的考虑分、秒计数器均为模 60 计数器;小时计数为模 24 计数器,同理可建一个 24 进制计数器的模块;(3) 校时设计的考虑数字钟校准有 3 个把握键:时校准、分校准和秒校准;微动开关不工作,计数器正常工作;按下微动开关后,计数器以8Hz 频率连续计数 如只按一下,就计数器增加一位 ,可调用元件库中的规律门建一个把握按键的模块,即建立开关去抖动电路 见书 70 页 ;(4) 报时设计的考虑可以将高频时钟分频得到约2KHz 和 1KHz 的音频,作为数字钟的报时频率;当电子钟显示 XX:59: 50 时,数字钟开头报时“ DO",连续一秒,而且每隔一秒报一下,直至显示XX:00: 00 时报“ DI" ,连续一秒后停止;最终输出至喇叭;应调用元件库中的规律门建一个把握报时的模块;(5) 建一个七段译码的模块欢迎下载精品学习资源因在系统可编程器件试验箱上的数码管没有经过译码,故要用 AHDL语言写一个七段译码的模块,且应考虑数码管为共阳极;数码管上的点 D2、D4、D6 应置 Vcc;四、课程设计所需要仪器1、运算机一台2、quartus 软件3、FPGA开发板 五、设计步骤1、模块介绍(1) ) 分频模块:产生 1Hz、1KHz、2KHz频率(2) ) 计数器模块:生成 60 进制、 24 进制计数器(3) ) 把握模块:按键把握、按键消抖(4) ) 显示模块: 7 段数码管显示器,分别显示小时、分钟、秒(5) ) 报时模块:进行整点报时2、各个模块的设计与仿真2.1 分频模块CLK 晶振频率 50MHZ ,分成 2KHZ,1KHZ,1HZ的信号;基准1HZ 信号作为时钟计时的秒计数时钟信号;分频的1KHZ,2KHZ信号用于报时电路的不同声讯;程序代码:library ieee;use ieee.std_logic_1164.all;entity fre is portclk ,sel: in std_logic;clk1hz,clk1khz,clk2khz:out std_logic;end fre;architecture beh of fre issignal data1khz,data2khz,data1hz : std_logic := '0';beginclk1hz <= data1hz;clk1khz <= data1khz;clk2khz <= data2khz;clk1khz_pro : processclk-产生 1khz信号variable cnt : integer range 0 to 24999;beginif clk'event and clk='1' then if cnt = 24999 thencnt := 0; data1khz <= not data1khz;欢迎下载精品学习资源elsecnt := cnt + 1;end if;end if;end process clk1khz_pro;clk2khz_pro : processclk-产生 2khz信号variable cnt : integer range 0 to 12499;beginif clk'event and clk='1' then if cnt = 12499 thencnt := 0; data2khz <= not data2khz;elsecnt := cnt + 1;end if;end if;end process clk2khz_pro;clk1hz_pro : processdata1khz-产生 1hz信号variable cnt : integer range 0 to 499;beginif data1khz'event and data1khz='1' thenif sel='0' then cnt:=0;else if cnt = 499 thencnt := 0;data1hz <= not data1hz;elsecnt := cnt + 1;end if;end if;end if;end process clk1hz_pro;end beh; 输入模块电路图:2.2 计数器模块由秒计数器,分计数器,时计数器组成了最基本的数字钟计时电路,两个六十进制计数器与二十四进制计数器组合构成;程序代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use IEEE.STD_LOGIC_ARITH.ALL;entity shuzizhong is portclk_change : in std_logic;s_en,m_en,h_en:in std_logic;欢迎下载精品学习资源sel:in std_logic;secout,minout,hourout :out std_logic; sl,sh,ml,mh,hl,hh:out std_logic_vector3 downto 0;a:out std_logic_vector15downto 0 ;end shuzizhong;architecture behav of shuzizhong is signallow_rega,high_rega,low_regb,high_regb,low_regc,high_regc :std_log ic_vector3 downto 0:="0000";signal sout,mout,hout :std_logic :='0';begin-秒的 60 进制进制counter_sec_l : processclk_change,s_en beginsl<=low_rega;sh<=high_rega;ml<=low_regb;mh<=high_regb;hl<=low_regc;hh<=high_regc;if clk_change'event and clk_change='1'欢迎下载精品学习资源thenif s_en='1' thenif low_rega="1001" thenlow_rega <= "0000";elselow_rega <= low_rega+'1';end if;end if;end if;欢迎下载精品学习资源end process counter_sec_l;counter_sec_h : processclk_change,s_en,low_rega beginif clk_change'event and clk_change='1'欢迎下载精品学习资源then="0101"then"0000";if s_en='1' thenif low_rega="1001" then if high_regahigh_rega <= elsehigh_rega <=欢迎下载精品学习资源欢迎下载精品学习资源high_rega+'1';end if;end if;end if;欢迎下载精品学习资源end if;end process counter_sec_h;sout <= '1' when low_rega="1001" and high_rega="0101"else '0';-分钟的 60进制设置counter_min_l : processclk_change,m_en beginif clk_change'event and clk_change='1'欢迎下载精品学习资源thenif m_en='1' thenif sout='1'or sel='0' then if low_regb="1001" thenlow_regb <= "0000";elselow_regb <= low_regb+'1';end if;end if;end if;end if;欢迎下载精品学习资源end process counter_min_l;counter_min_h : processclk_change,m_en,low_regb beginif clk_change'event and clk_change='1'欢迎下载精品学习资源then"0000";if sout='1'or sel='0' then if m_en='1' thenif low_regb="1001" thenif high_regb ="0101"then high_regb <=elsehigh_regb <=欢迎下载精品学习资源欢迎下载精品学习资源high_regb+'1';end if;end if;end if;欢迎下载精品学习资源end if;end if;end process counter_min_h;mout <= '1' when low_regb="1001" and high_regb="0101"and sout='1' else '0';-小时的 24 进制设置counter_hour_l : processclk_change,h_en欢迎下载精品学习资源thenbeginif clk_change'event and clk_change='1'if h_en='1' thenif mout='1'or sel='0' thenif low_regc="1001"or hout='1' thenlow_regc <= "0000";elselow_regc <= low_regc+'1';end if;end if;end if;end if;欢迎下载精品学习资源end process counter_hour_l;counter_hour_h : processclk_change,h_en,hout beginif clk_change'event and clk_change='1' then欢迎下载精品学习资源thenhigh_regc+'1';if mout='1'or sel='0' then if h_en='1' thenif hout='1' thenhigh_regc<="0000";else if low_regc="1001" high_regc <=欢迎下载精品学习资源end if;end ifend if;end if;end ifend process counter_hour_h;hout <= '1' when low_regc="0011" and high_regc="0010" else '0';secout<=sout;minout<=mout;hourout<=hout;a<=high_regb&low_regb&high_rega&low_rega;end behav;输入模块电路图:2.3 把握模块分五个状态 0 状态正常计时,按下按键进入下一状态开头调时模式 1,按下按键进入调秒模式 2 ,按下按键进入调分模式 3,按下按键进入调小时模式 4. 按下按键复原正常计时模式;程序代码:欢迎下载精品学习资源library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity key_press isportset ,mode: in std_logic;clk1khz,clk1hz: in std_logic;secout,minout: in std_logic;clk_change,clk2hz_en:out std_logic;sel,s_ce,m_ce,h_ce:out std_logic;s_en,m_en,h_en:out std_logic ;endkey_press;architecture beh of key_press issignal key1,key2:std_logic;signal sce_reg, mce_reg ,hce_reg:std_logic;signal ssl,ssen,mmen,hhen:std_logic;signal con : integer range 0 to 4 :=0;-按键按下(延时)beginkey_press2 : processset,clk1khzvariable cnt :integer range 0 to 999;beginif set='0' thenif clk1khz'event and clk1khz='1'then if cnt=50 and set='0' thencnt :=cnt+1; key2 <=欢迎下载精品学习资源'1';else cnt:=cnt+1; key2 <= '0';end if;end if;else欢迎下载精品学习资源cnt:=0; key2<='0';end if;end process key_press2key_press1 : processmode,clk1khz;variable cnt :integer range 0 to 999;欢迎下载精品学习资源'1';beginif mode='0' thenif clk1khz'event and clk1khz='1'then if cnt=50 and mode='0' thencnt :=cnt+1; key1 <=else cnt:=cnt+1; key1 <= '0';end if;end if;欢迎下载精品学习资源elsecnt:=0; key1<='0';end if;end process key_press1;count : processkey1,key2beginif key1'event and key1='1' then if con=4 thencon<=0;elsecon<=con+1;end if;end if;end process count;con_pro : processconbegincase con iswhen 0 => ssl<='1'sce_reg <= '0';ssen<='1';<='1'mce_reg <= '0';mmenhce_reg <= '0';hhen<='1';clk2hz_en <='0';when 1 => ssl<='0';sce_reg <= '0';ssen<='1';mce_reg <= '0';mmen<='1';<='1'hce_reg <= '0';hhenclk2hz_en <='1';when 2 => ssl<='0';sce_reg <= '1';ssen<='1';mce_reg <= '0';mmen<='0';hce_reg <= '0';hhen<='0';clk2hz_en <='1' when 3 => ssl<='0';sce_reg <= '0';ssen<='0';欢迎下载精品学习资源<='1';<='0';<='0';<='0';<='1';<='1';<='1';<='1';mce_reg <= '1';mmenhce_reg <= '0';hhenclk2hz_en <='1';when 4 => ssl<='0';sce_reg <= '0';ssenmce_reg <= '0';mmenhce_reg <= '1';hhenclk2hz_en <='1';when others => ssl<='0';sce_reg <= '0';ssenmce_reg <= '0';mmenhce_reg <= '0';hhenclk2hz_en <='0';end case;欢迎下载精品学习资源end process con_pro;sel_pro : processssl begincase ssl iswhen '0'=> s_ce<=sce_reg;m_ce<=mce_regh_ce<=hce_reg;clk_change<=key2;when '1'=> s_ce<=ssen;m_ce<=mmen;h_ce<=hhen;clk_change<=clk1hz;when others=> s_ce<=ssen;m_ce<=secout;h_ce<=minout;clk_change<=clk1hzend case;end process sel_pro;sel<=ssl; s_en<=ssen;m_en<=mmen ; h_en<=hhen;end beh;输入模块电路图 :欢迎下载精品学习资源2.4 数码管支配程序代码:library ieee;use ieee.std_logic_1164.all;entity display is portdatain : in std_logic_vector3 downto 0;dataout : out std_logic_vector7 downto 0;end display;architecture duan of display is beginprocessdatain begincase datain iswhen"0000"=>dataout<="11000000";- dp,g,f,e,d,c,b,awhen "0001" => dataout <="11111001";when "0010" => dataout <="10100100"when "0011" => dataout <="10110000";when "0100" => dataout <="10011001";when "0101" => dataout <="10010010"when "0110" => dataout <="10000010";when "0111" => dataout <="11111000";when "1000" => dataout <="10000000"when "1001" => dataout <="10010000";when "1010" => dataout <="10111111";when "1011" => dataout <="10000011";when "1100" => dataout <="10100111"when "1101" => dataout <="10100001";when "1110" => dataout <="10000110";when "1111" => dataout <="10001110"when others => null;end case;end process;end;输入模块电路图:2.5 显示模块使用七段数码管显示小时、分钟与秒程序代码:library ieee;use ieee.std_logic_1164.all;entity scan is port欢迎下载精品学习资源clk1khz: in std_logic;sl,sh,ml,mh,hl,hh : in std_logic_vector3 downto 0;clk2hz_en: in std_logic;s_ce,m_ce,h_ce: in std_logic;en_out: out std_logic_vector7 downto 0;dataout: out std_logic_vector3 downto 0;end scan;architecture beh of scan issignal cnt: integer range 0 to 7;signal en: std_logic_vector7 downto 0;signal clk2hz: std_logic;signal h_ce_reg,m_ce_reg,s_ce_reg : std_logic;beginh_ce_reg <= not h_ce;m_ce_reg <= not m_ce;s_ce_reg <= not s_ce;cnt_pro : processclk1khz beginif clk1khz'event and clk1khz='1' then if cnt = 7 thencnt <= 0;elsecnt <= cnt + 1;end ifend if;end process cnt_pro;clk2hz_pro :processclk1khzvariable c : integer range 0 to 499 := 0;beginif clk1khz'event and clk1khz='1' then if clk2hz_en ='1' thenif c =499 thenc := 0; clk2hz <= not clk2hz;elsec := c + 1;end if;elseclk2hz <= '0';end if;end if;end process clk2hz_pro;scan_pro : processcnt,sl,sh,ml,mh,hl,hh begincase cnt is欢迎下载精品学习资源when 0 => dataout <= slwhen 1 => dataout <= sh; en <= "11111110"; en <= "11111101";when 2 => dataout <= ml; en <= "11110111";when 3 => dataout <= mhwhen 4 => dataout <= hl; en <= "11101111"; en <= "10111111";when 5 => dataout <= hh; en <= "01111111";when 6 => dataout <= "1010";en <= "11111011";when 7 => dataout <= "1010"when others => null;en <= "11011111";end case;end process scan_pro;en_out <= en or clk2hz & clk2hz or h_ce_reg & h_ce_reg & clk2hz & clk2hz & clk2hz or m_ce_reg & m_ce_reg & clk2hz& clk2hz & clk2hz or s_ce_reg & s_ce_reg;end beh; 输入模块电路图:2.6 报时模块利用蜂鸣器进行整点报时程序代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use IEEE.STD_LOGIC_ARITH.ALL;-整点报时entity baoshi is portclk1khz,clk2khz : in std_logic;a:in std_logic_vector15 downto 0;sel:in std_logic;bell:out std_logic;end baoshi; architecture zhong of baoshi issignal c1,ring:std_logic;beginring_bell :processclk1khz,clk2khz begincase a iswhen "0101100101010000" => c1<=clk1khz;when "0101100101010010" => c1<=clk1khz;when "0101100101010100" => c1<=clk1khz;when "0101100101010110" => c1<=clk1khz;when "0101100101011000" => c1<=clk1khz;when "0000000000000000" => c1<=clk2khz;欢迎下载精品学习资源when "0011000000000000" => c1<=clk2khz;when others => c1<='0';end case;end process ring_bell;bs: processc1 beginif sel='1' then if c1='1' thenring<='0';else ring<='1';end if;end if;end process bs;bell<=ring;end zhong;输入模块电路图:整体模块电路图六、调试中遇到的问题及解决的方法:1、编程时,经常导致语法错误,如:“;”没有写上,变量类型没有预先标明,前后变量名字由于缺少一个或多一个字母而导致出错;解决方法:对比错误,仔细检查程序,看哪个地方的标点,变量没有写上或标明;2、进行编译或波形仿真时,经常得到的不是预想中的结果;解决方法:将需要编译或进行仿真的实体文件置顶,经检错无误后,进行波形仿真,在仿真之前需要合理设置仿真终止时间和信号周期;3、在把握时间的显示的时候,由于变量太多多发觉不能完全的把握住变量,导致显示的时候显现了乱码,数码管显示不正常解决方法:削减变量,仔细推敲,合理命名;七、心得体会一个多星期的课程设计让我受益匪浅,也让我真正明白理论与实践相结合的 重要性;通过具体实践才能让自己清楚哪些学问已经把握,哪些学问仍需巩固 加强;与此同时,我也对 EDA以及 VHDL语言有了进一步明白,对于其结构、语法、功能等熟识不少;当然,我目前所做的仍仅仅只是一些基本操作,要想真 正将其融会贯穿仍需要今后更多的学习与实践;虽然只是一个小设计,我却也从中学到了不少设计流程和一些相关问题;设计是一个特别严谨的过程,容不得任凭和马虎;要想快速而高效地完成一项设计,必需先有一个清楚明白的设计思路,设想好一个整体框架,然后在此基础上,逐步将各个部分功能进行完善;在设计的过程中,也曾遇到不少困难,但正所谓坚持就是胜利,要想取得胜利,必需要有努力付出,这样所取得的结果才更有意义;欢迎下载精品学习资源版权申明本文部分内容,包括文字、图片、以及设计等在网上搜集整理;版权为潘宏亮个人全部This article includes some parts, including text, pictures, and design. Copyright is Pan Hongliang's personal ownership.用户可将本文的内容或服务用于个人学习、争论或观看,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵害本网站及相关权益人的合法权益;除此以 外,将本文任何内容或服务用于其他用途时,须征得本人及相关权益人的书面许可,并支付酬劳;Users may use the contents or services of this article for personal study, research or appreciation, and other non-commercial or non-profit purposes, but at the same time, they shall abide by the provisions of copyright law and other relevant laws, and shall not infringe upon the legitimate rights of this website and it