eda数字钟设计.docx_第1页
eda数字钟设计.docx_第2页
eda数字钟设计.docx_第3页
eda数字钟设计.docx_第4页
eda数字钟设计.docx_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

eda设计()实验报告 第 23 页 共 23 页摘 要本实验利用maxplus ii软件,结合所学的数字电路的知识设计一个24时多功能数字钟,具有正常时、分、秒计时,能够动态显示,保持、清零、快速校分、快速校时以及整点报时等功能。文章分析了整个电路的工作原理,还分别说明了各子模块的设计原理和调试、仿真、编程下载的过程,并对最终结果进行总结,并且提出了在实验过程中所遇到的问题和解决的方案。通过本实验,初步掌握了vhdl语言的使用,体会到了利用软件设计电路的方便快捷高效。目录一、设计要求说明2二、方案论证3三、各子模块设计原理31.分频模块32.计时器模块43.显示模块94.整点报时模块145.顶层原理图15四、仿真与调试151.分频器仿真162.显示模块调试163.计时模块仿真与调试17五、实验中遇到的问题及解决方法18六、实验收获与感受19参考文献20多功能数字计时器设计一、 设计要求说明1. 能进行正常的时,分,秒计时功能,完成一天二十四小时的计时;2提供六个数码管动态显示时,分,秒;3. 对于时钟要提供校正功能,能对于分、时分别提供快速校正。4. 时钟具有整点报时功能,当时钟计到每个小时的5953”时开始报时,在5953”, 5955”,5957” 时发出低音, 5959”时发出高音;二、 方案论证进行这次实验采用了vhdl语言进行设计,采用自顶向下,逐步细化的设计思路,将整个计时器设计分为三层模块进行设计,在上层模块中调用底层模块,最后在顶层中采用原理图,构成整个设计内容。三、 各子模块设计原理1. 分频模块在本次实验中,需要多次用到各种频率的时钟信号,比如计时器所需的1hz时钟,比如报时所需2khz,3khz时钟,而实验箱提供的是频率为16384hz的时钟信号,所以需要使用分频器产生自己需要的各种频率。以下以产生1hz频率的分频器为例,vhdl语言如下:library ieee;use ieee.std_logic_1164.all;entity fenpin1 isport(clk_in:instd_logic; clk_out:outstd_logic);end fenpin1;architecture behave of fenpin1 isconstant n:integer:=16384-1;signal m:integer range 0 to n;beginprocess(clk_in)beginif rising_edge(clk_in) thenif m = n/2 thenm=m+1;clk_out=0;elsif m n thenm=m+1;clk_out=1;else m=0;end if;end if;end process;end behave;如需要改变所获得的频率,只需要改变上述程序中常数n。设所需频率为x,则公式为n=16384/x。2. 计时器模块要完成本次实验的设计要求,进行24小时内的计时,需要一个模24、两个模60的计数器,并对他们进行连接。并在其中加入校时、校分电路,原理是通过一个开关,改变分钟、小时计数器的ci端,实现校时、校分。模60计数器,vhdl语言如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity counter60 isport( ci:instd_logic; nreset:in std_logic; load:instd_logic; d:instd_logic_vector(7 downto 0); clk:in std_logic; co:outstd_logic; qh:bufferstd_logic_vector(3 downto 0); ql:bufferstd_logic_vector(3 downto 0);end counter60;architecture behave of counter60 isbeginco=1 when(qh=0101 and ql=1001 and ci=1) else 0;process(clk,nreset)beginif(nreset=0) thenqh=0000;ql=0000;elsif(clkevent and clk=0) thenif(load=1) thenqh=d(7 downto 4);ql=d(3 downto 0);elsif(ci=1) thenif (ql=9) thenql=0000;if(qh=5) thenqh=0000;elseqh=qh+1;end if;elseql=ql+1;end if;end if;end if;end process;end behave;模24计数器,vhdl语言如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity counter24 isport( ci:instd_logic; nreset:in std_logic; load:instd_logic; d:instd_logic_vector(7 downto 0); clk:in std_logic; co:outstd_logic; qh:bufferstd_logic_vector(3 downto 0); ql:bufferstd_logic_vector(3 downto 0);end counter24;architecture behave of counter24 isbeginco=1 when(qh=0010 and ql=0011 and ci=1) else 0;process(clk,nreset)beginif(nreset=0) thenqh=0000;ql=0000;elsif(clkevent and clk=0) thenif(load=1) thenqh=d(7 downto 4);ql=d(3 downto 0);elsif(ci=1) thenif (ql=9) thenql=0000;qh=qh+1;elsif (ql=3) thenif (qh=2) thenqh=0000;ql=0000;else ql=ql+1;end if;else ql=ql+1;end if;end if;end if;end process;end behave;通过开关改变在两路信号中选择的字模块,vhdl语言如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity change isport(switch:instd_logic; clk_in1:instd_logic; clk_in2:instd_logic; clk_out:outstd_logic );end change;architecture behave of change isbeginprocess(switch,clk_in1,clk_in2)beginif(switch = 0) thenclk_out=clk_in1;elseclk_out=clk_in2;end if;end process;end behave; 然后需要建立一个原理图文件,对上述三个子模块进行组合,然后再使用这三个子模块,形成整个计数模块,原理图文件如下如下:以上,就形成了一个完整的带校时、校分功能的计数器电路,可以在后面的设计中被使用。3. 显示模块在本次实验中,显示部分的硬件为8个七段数码管,所以根据硬件与设计要求设计了显示模块。显示模块由一个模6计数器,一个4-7译码器,一个3-8译码器以及一个4路八选一数据选择器构成,采用动态显示原理进行时、分、秒共六位的显示。模6计数器,如需进行8个数码显示管的输出,只需将模6改为模8即可,vhdl语言如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity counter6 isport( clk:in std_logic; q:bufferstd_logic_vector(2 downto 0) );end counter6;architecture behave of counter6 isbeginprocess(clk)beginif(clkevent and clk=1) thenif (q=5) thenq=000;elseqdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeoutdecodeout=zzzzzzzz;end case;end process;end truthtable;4路八选一数据选择器,vhdl语言如下:library ieee;use ieee.std_logic_1164.all;entity v8mux8 is port(datain0,datain1,datain2,datain3,datain4,datain5,datain6,datain7:in std_logic_vector(3 downto 0); sel:in std_logic_vector(2 downto 0); dataout:out std_logic_vector(3 downto 0) );end v8mux8;architecture truthtable of v8mux8 isbeginwith sel selectdataout=datain0 when 000,datain1 when 001,datain2 when 010,datain3 when 011,datain4 when 100,datain5 when 101,datain6 when 110,datain7 when others;end truthtable;在程序包中将上述四个子模块形成元件后,再将四个模块进行组合,形成整个显示模块,原理为:给模6计数器1khz的时钟信号,使它产生从“000”到“111”的循环,作为控制信号,这个信号传给3-8译码器,就以很快的速率依次选中6片数码显示管,而控制信号传给4路八选一数据选择器,就决定哪一路的信号传给4-7译码器,最终传给数码管,形成动态显示。原理图如下:4. 整点报时模块报时模块的原理很简单,就是判断当前的时、分状态,然后根据判断的结果,将不同频率的时钟信号送给蜂鸣器即可,用嵌套的if语句可以很容易的实现,vhdl语言如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity beep isport(clk_1,clk_2:instd_logic; clk_out:outstd_logic; qmh,qml,qsh,qsl:instd_logic_vector(3 downto 0);end beep;architecture behave of beep isbeginprocess(qsl)beginif(qmh=0101 and qml=1001) thenif(qsh=0101) thenif(qsl=0011 or qsl=0101 or qsl=0111) thenclk_out=clk_1;elsif(qsl=1001) thenclk_out=clk_2;end if;end if;end if;end process;end behave;5. 顶层原理图四、 仿真与调试1. 分频器仿真由于48m分频在仿真上耗时太长,所以将分频器中常数n改为10,进行10分频的仿真,仿真结果如上图,说明分频器能达到预定效果。2. 显示模块调试为了对显示模块进行调试,另编写了一个专门用于调试的程序,vhdl语言如下:library train;use tpkg.all;library ieee;use ieee.std_logic_1164.all;entity led_test isport(clk,ci,nreset:in std_logic; d:instd_logic_vector(3 downto 0); decodeout:outstd_logic_vector(7 downto 0); dataout:out std_logic_vector(6 downto 0) );end led_test;architecture behave of led_test issignal qq:std_logic_vector(3 downto 0);signal clk3k:std_logic;signal qd:std_logic_vector(2 downto 0);beginf2:fenpin3k port map(clk,clk3k);c8:counter8 port map(clk3k,qd);d1:decode47 port map(d,dataout);d2:decode38 port map(qd,decodeout);m1:v8mux8 port map(d,d,d,d,d,d,d,d,qd,qq);end behave;只需将d接到三个

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论