2022年EDA课程设计——基于VHDL语言的数字时钟设计.docx
名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -一、设计要求 .1 二、设计原理及框图 .1 1、设计原理 .1 2、结构框图 .1 三、 设计过程 .2 1、模块化设计 .22、顶层文件生成.3四、仿真调试过程 .41、各模块时序仿真图.4细心整理归纳 精选学习资料 2、仿真过程中遇到的问题.5 第 1 页,共 10 页 五、设计体会及收成.5 - - - - - - - - - - - - - - - - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -一、设计要求1、稳固的显示时、分、秒;2、当电路发生走时误差时,要求电路有校时功能;3、电路有整点报时功能;报时声响为四低一高,最终一响高音正好为整点;二、设计原理及框图1、设计原理系统框图由六个模块组成,分别为:秒、分、时计数模块,整点报时模块,LED 动态显示扫描模块,调时掌握模块组成;其工作原理是:基准脉冲输入信号同时加到秒、分、时、分隔符的脉冲输入端,采纳并行计数的方式,秒的进位接到分的使能端上,秒的使能借到分隔符的使能上,分得接到时的使能端上,完成秒、分、时和分隔符的循环计数;整点报时是依据分的 A 、B 输出同时为 0 时,整点报时模块输出高电平掌握报时;LED 显示扫描模块依据输入的扫描信号 CKDSP 轮番选通秒、分、时、分隔符的 8 位八段数码管,LED 显示译码器完成计数器输出的 BCD 的译码;2、结构框图显示模块秒计时模块 整点报时分计时模块数字时钟模块调时掌握时计时模块模块0细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 2 页,共 10 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -三、 设计过程1、模块化设计(1)秒计时模块 秒计时模块由一个 60 位计数器为主体构成,其输 入输出端口组成为:Clk :计时时钟信号 Reset:异步清零信号 Setmin:分钟设置信号 Enmin:使能输出信号 Daout6:0 :BCD 码输出(2)分计时模块 分计时模块由一个 60 位计数器为主体构成,其输入 输出端口组成为:Clk 、clk1 :计时时钟信号 Reset:异步清零信号 Sethour:小时设置信号 Enmin:使能输出信号 Daout6:0 :BCD 码输出(3)时计时模块 时计时模块由 24 位计数器为主体构成,其输入输出 端口组成为:Clk :计时时钟信号 Reset:异步清零信号 Daout6:0 :BCD 码输出(4)显示模块 系统时间输出由六个七段数码管显示;显示的数据是各计时模块给出的 BCD 码;1细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 3 页,共 10 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -(5)调时掌握模块该模块主要用于调剂时、分显示,用于“ 对表 ” ;(6)整点报时模块在时钟整点的时候产生扬声器驱动信号;由时钟计时模块中分钟的进行信号进行掌握;当 contr_en 为高电平常,将输入信号 clk 送到输出端 speak 用于驱动扬声器,同时在 clk 的掌握下,输出端lamp2.0 进行循环移位;输出掌握模块有扬声器控制器子模块组成;2、顶层文件生成前面已经完成了电子时钟电路的各个组成部分的设计,下面把这些组成部分组装起来,形成完整的总体设计;该电子时钟的命名为 clock ,其外部端口如右图所示;各个输入 / 输出端口的作用如下:(1)clk 为外部时钟信号,其频率为 1Hz ,reset 为异步清零信号 . (2)sethour 和 setmin 分别为调时调分脉冲输入信号,当 en_set为高电平常,每来一个 sethour 脉冲或 setmin 脉冲,时、分输出将分别加 1;(3)second6.0为秒的个位和十位BCD 码输出,min6 0为分钟的个位和十位BCD 码输出, hour6.0 为小时的个位和十位BCD 码输出,它们最终中用来驱动七段数码管, lamp2.0 为花样显示输出信号,speak 为整点报时扬声器驱动信号细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 4 页,共 10 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -四、仿真调试过程1、各模块时序仿真图(1)秒计数器仿真图(2)分计数器仿真图(3)时计数器仿真图(4)整点报时仿真图3细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 5 页,共 10 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -(5)调时调分仿真图(6)LED 显示译码仿真图2、仿真过程中遇到的问题(1)由于距离学习 EDA 技术课程的时间较长,遗忘了部分课程内容,对仿真软件不熟识造成多次仿真失败;就此问题我仔细复习了所学的 骤重新进行了仿真,问题得以解决;EDA 相关课程,依据课本上介绍的步(2)由于仿真过程中对各部分时序波形应实行什么样的鼓励波形不清晰,给仿真过程带来 了较大的麻烦;通过查阅相关资料,阅读网上一些比较成熟的论文,确定了仿真过程中的 相关参数;五、设计体会及收成本次课程设计我做出的数字时钟能够正确的进行整点报时,显示时间,但是对于调时 调分功能不能正确显示;经过努力,简易电子时钟的设计基本上算是完成了,在整个设计 中,我最大的体会就是:对学过的学问遗忘太多;在本次的课程设计中,我发觉了许多问 题,同时做起来也很难不顺手,看着简洁的电路,要动手把它设计出来实非易事,主要原 因对相关应用软件的不熟识,这就要求我们在以后的学习中,应当留意复习的重要性,对 学过的学问要经常复习,加深记忆,更重要的是我们要学会把从书本上学到的学问和实际 电路联系起来,这不论对我们以后的学习仍是就业,都会起到很大的促进和帮忙;我信任,通过这次的课程设计,在下一阶段的学习中我们会更加努力,力争把这门课学好学精;同 时通过本次课程设计,巩固了我们以前学过的专业学问,通过这次的程序设计,使我们对 数字系统结构也有了更进一步的明白与熟识,同时对数据库软件技术,语 言等系列学问都有了肯定的明白与熟识;使用技术开发页面的才能也有了提高,也 使我们把理论与实践从正真意义上结合了起来,考查了我们的动手才能和查阅相关资料的 才能,仍有组织材料的才能;通过此次实践,我们从中可以找出自己学问的不足与 欠缺,以便我们在日后的学习中得以改进与提高;经过本次设计使我们对高校四年期间所 学习到的学问得以进一步实践,这将对我们走出校内,走向社会,走向工作岗位奠定坚实 的基础;4细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 6 页,共 10 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -附 录1、秒计数单元代码 2、分计数单元代码LIBRARY ieee; LIBRARY ieee;use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;ENTITY second IS ENTITY minute ISPORT PORTclk,reset,setmin:IN STD_LOGIC; enmin:OUT STD_LOGIC;daout:out std_logic_vector6 downto 0;clk,clk1,reset,sethour:IN STD_LOGIC; enhour:OUT STD_LOGIC;daout:out std_logic_vector6 downto 0;END entity second; END entity minute;ARCHITECTURE fun OF second ISARCHITECTURE fun OF minute ISSIGNAL count:STD_LOGIC_VECTOR6 SIGNAL count:STD_LOGIC_VECTOR6 downto 0;downto 0;SIGNAL enmin_1,enmin_2:STD_LOGIC;SIGNAL enhour_1,enhour_2:STD_LOGIC;BEGIN BEGINdaout<=count; daout<=count;enmin_2<=setmin and clk; enmin<=enmin_1 or enmin_2;processclk,reset,setminenhour_2<=sethour and clk1; enhour<=enhour_1 or enhour_2;processclk,reset,sethourbegin beginifreset='0' then count<="0000000" ifreset='0'thenelsifclk'event and clk='1'then count<="0000000"ifcount3 downto 0="1001"then ifcount<16#60#thenelsifclk'event and clk='1'then ifcount3 downto 0="1001"thenifcount="1011001"then ifcount<16#60#thenenmin_1<='1'count<="0000000"ifcount="1011001"thenelse enhour_1<='1'count<=count+7; count<="0000000"end if; ELSEelse count<=count+7;count<="0000000" end if;end if; elseelsifcount<16#60#then count<="0000000"count<=count+1; end if;enmin_1<='0' after 100 ns; elsifcount<16#60#thenelse count<=count+1;end if; enhour_1<='0'after 100 ns;end if; elseend process; count<="0000000"end fun ; end if;5细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 7 页,共 10 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -end if; ARCHITECTURE fun OF deled ISend process; BEGINEND fun; led<="1111110"when num="0000"else3、时计数单元代码"0110000"when num="0001"elseLIBRARY ieee; "1101101"when num="0010"elseuse ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;"1111001"when num="0011"else "0110011"when num="0100"elseENTITY hour IS "1011011"when num="0101"elsePORT "1011111"when num="0110"elseclk,reset:IN STD_LOGIC; daout:out std_logic_vector5 downto 0;"1110000"when num="0111"else "1111111"when num="1000"elseEND entity hour; "1111011"when num="1001"elseARCHITECTURE fun OF hour IS"1110111"when num="1010"elseSIGNAL count:STD_LOGIC_VECTOR5 "0011111"when num="1011"elsedownto 0; "1001110"when num="1100"elseBEGIN "0111101"when num="1101"elsedaout<=count; "1001111"when num="1110"elseprocessclk,reset"1000111"when num="1111"begin END fun;ifreset='0'then 5、调时掌握单元代码count<="000000" LIBRARY ieee;elsifclk'event and clk='1'then if count3 downto 0="1001"then ifcount<=16#23#thenuse ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all;count<=count+7; ENTITY seltime ISelse PORTcount<="000000"clk1,reset:IN STD_LOGIC;end if; sec,min:IN STD_LOGIC_VECTOR6 downto elsifcount<16#23#then 0;count<=count+1; hour:in std_logic_vector5 downto 0;else daout:OUT STD_LOGIC_vector3 downto 0;count<="000000" dp:OUT std_LOGIC;end if; sel:out std_logic_vector2 downto 0;end if; END seltime;end process; ARCHITECTURE fun OF seltime ISEND fun ;SIGNAL count:STD_LOGIC_vector2 4、显示单元代码 downto 0;LIBRARY ieee; BEGINuse ieee.std_logic_1164.all; sel<=count;use ieee.std_logic_unsigned.all; processclk1,resetENTITY deled IS beginPORTnum:IN std_logic_vector3 downto 0; ifreset='0'thenled:OUT std_logic_vector6 downto 0; count<="000"end deled; elsifclk1'event and clk1='1'then6细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 8 页,共 10 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -ifcount>="101"then ifcount1>="10"thencount<="000" count1<="00"else elsecount<=count+1; count1<=count1+1;end if; end if;end if; end if;case count is end if;when"000"=>daout<=sec3 downto 0;dp<='0' end process speaker;when"001"=>daout3<='0'daout2 downto lamper:processclk0<=sec6 downto 4;dp<='0' beginwhen"010"=>daout<=min3 downto ifrising_edgeclkthen0;dp<='1' ifcoun<="10"thenwhen"011"=>daout3<='0'daout2 downto ifcoun="00"then0<=min6 downto 4;dp<='0' lamp<="001"when"100"=>daout<=hour3 downto elsifcoun="01"then0;dp<='1' lamp<="010"when others=>daout3 downto 2<="00" elsifcoun="10"thendaout1 downto 0<=hour5 downto lamp<="100"4;dp<='0' end if;end case; coun<=coun+1;end process; elseend fun; coun<="00"6、整点报时单元代码 end if;LIBRARY ieee; end if;use ieee.std_logic_1164.all; end process lamper;use ieee.std_logic_unsigned.all; END fun;ENTITY alert IS 7、顶层代码PORT library ieee;clk:IN STD_LOGIC;use ieee.std_logic_1164.all;dain:IN STD_LOGIC_VECTOR 6 entity clock_top isDOWNTO 0;2 portclk,reset,setmin,sethour,clkdsp:in speak:OUT STD_LOGIC;std_logic;lamp:OUT STD_LOGIC_VECTOR speaker:out std_logic;DOWNTO 0;lamp:out std_logic_vector2 downto 0;END alert;sel:out std_logic_vector2 downto 0;ARCHITECTURE fun OF alert ISa,b,c,d,e,f,g,dpout:out std_logic;signal coun:std_logic_vector 1 downto 0; end clock_top;signal count1:std_logic_vector 1 downto 0;architecture a of clock_top isBEGIN COMPONENT secondspeaker:processclk PORTbegin clk,reset,setmin:IN STD_LOGIC;speak<=count11; ifclk'event and clk='1'thendaout:out std_logic_vector6 downto 0; enmin:OUT STD_LOGIC;ifdain="0000000"then END COMPONENT;7细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 9 页,共 10 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -COMPONENT minute 0;PORTsignal seltime_daout:std_logic_vector3 clk,clk1,reset,sethour:IN STD_LOGIC;downto 0;enhour:OUT STD_LOGIC;signal ledout:std_logic_vector6 downto 0;daout:out std_logic_vector6 downto 0; beginEND COMPONENT;a<=ledout6;b<=ledout5;c<=ledout4;d<=lCOMPONENT hour edout3;PORT e<=ledout2;f<=ledout1;g<=ledout0;clk,reset:IN STD_LOGIC;u1: second port mapreset=>reset,daout:out std_logic_vector5 downto 0; clk=>clk,END COMPONENT; setmin=>setmin,COMPONENT alert enmin=>enmin_re,PORT daout=>second_daout;clk:IN STD_LOGIC;u2:minute port mapclk=>enmin_re,dain:in std_logic_vector6 downto 0; clk1=>clk,lamp:out std_logic_vector2 downto 0; reset=>reset,speak:OUT STD_LOGIC; sethour=>sethour,END COMPONENT; enhour=>enhour_re,COMPONENT seltime daout=>minute_daout;PORT u3:hour port mapclk=>enhour_re,clk1,reset:IN STD_LOGIC; reset=>reset,sec,min:in std_logic_vector6 downto 0; daout=>hour_daout;hour:in std_logic_vector5 downto 0;u4:alert port mapclk=>clk,dp:out std_logic; dain=>minute_daout,daout:out std_logic_vector3 downto 0; speak=>speaker,sel:OUT STD_LOGIC_vector2 downto 0; lamp=>lamp;END COMPONENT;u5:seltime port mapclk1=>clkdsp,COMPONENT deled reset=>reset,PORT sec=>second_daout,num:IN STD_LOGIC_vector3 downto 0; min=>minute_daout,led:out std_logic_vector6 downto 0; hour=>hour_daout,END COMPONENT; daout=>seltime_daout,signal enmin_re,enhour_re:std_logic; dp=>dpout,signal sel=>sel;second_daout,minute_daout:std_logic_vectoru6:deled port mapnum =>seltime_daout,6 downto 0; led=>ledout;signal hour_daout:std_logic_vector5 downto end a;8细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 10 页,共 10 页 - - - - - - - - -