基于VHDL的数字钟设计及其仿真_第1页
基于VHDL的数字钟设计及其仿真_第2页
基于VHDL的数字钟设计及其仿真_第3页
基于VHDL的数字钟设计及其仿真_第4页
基于VHDL的数字钟设计及其仿真_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

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

文档简介

基于VHDL的数字钟设计及其仿真结构化设计 元件例化 配置 原理图一引言所谓数字钟是指利用电子电路构成的计时器,相对机械钟而言,数字钟能达到准确计时,同时能对该种进行调整。当然,在此基础上还能够实现整点报时,定时报闹等功能。设计过程采用系统设计的方法,先分析任务得到系统要求,然后进行总体设计,划分子系统,然后进行详细设计,决定各个功能子系统的VHDL程序,最后进行调试仿真。通过此次设计,对基于VHDL的结构化描述有深刻理解,为今后的集成电路设计打下坚实的基础。二设计任务和要求 对于时钟,最基本的要求应具有时分秒的计数功能。对于秒必须满足每满60s,分要记一个数,并且秒重新从零计起;对于分必须满足60min,小时要记一个数,并且分重新从零计起,对于时满24后也应重新从零计起。此外当数字中走慢或走快时,还应能予以调整。所以要求设计的数字中电路应具有以下功能:1. 具有十分秒计数功能,并进行十进制数字显示。2. 能分别进行时分的手动校正。三工作原理时钟信号的频率有振荡器产生,由于技术最小单位为1s,所以时钟信号经分频器后输出频率为1Hz的秒脉冲clk;而校准信号的频率应高于1Hz,若取0.5,则时钟信号经另一个分频器后输出频率为2Hz的校准信号脉冲clk1。当无校准信号作用,即校分信号xf、校时信号xs为高电平,整个电路处于正常计数的工作状态时分秒计数器采用同步计数方式其时钟脉冲端均接有分频器输出的时钟信号clk.。en为使能端,高电平有效。三个计数器的复位端clr置入数据控制端ld都接高电平,故其置入端d70失效,且各计数器输出端分别接译码显示电路。当有校准信号时,不妨假设只有校分信号,即xf=0、xf=1,则在二选一数据选择器的控制下,分计数器的en端将始终接高电平,即分计数器将独立于秒计数器自行独立计数,但其结果仍影响到时计数器,因为此时没有校时信号。同理,当只有校时信号或同时具有校时、校分信号,情况同上述分析一样。四各个模块的VHDL仿真图以及计数部分校正仿真图 (图一、无时间调整下数字钟的仿真运行图) (图二、利用xs信号校对时间的小时数的仿真结果图)(图三、利用xf信号校对时间的分钟数的仿真结果图)六十进制计数电路模块对应的仿真波形如下图所示了,clk为时钟脉冲,clr为复位端,en为使能控制端,ld位并行置数输入端,ql、qh和co分别为六十进制计数器的个位十位和进位输出,由仿真波形可以看出,个位ql每从09计10个数,十位qh计一个数,当qh每计到5时,进位co输出一个脉冲,说明计数器没来60个clk时钟脉冲,进位co产生一个脉冲,实现六十进制计数。 (图四、带有异步清零和置数功能的60进制计数器元件仿真图)二分频电路所对应的仿真波形如下图所示,clr为复位端,clk为2Hz时钟脉冲,当clr为1时,二分频电路有效,cnt=2clk,实现了分频作用。 (图五、对时钟的二倍分频元件仿真图)2选1数据选择器模块对应的仿真波形如下图所示,有仿真波形可以看出,当选择输入S=0时,输出y=a;当选择S=1时,输出y=b,实现了2选1数据选择功能。 (图六、2选1数据选择元件仿真图) (图七、D触发器元件仿真图)二十四进制计数电路模块对应的仿真波形如下图所示,有仿真波形可以看出,计数器每来24个clk时钟脉冲,进位co产生一个脉冲,实现了二十四进制计数。 (图八、带有异步清零和置数功能的24进制计数器元件仿真图)五整个过程各个模块VHDL源程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity counter isport(clk: in std_logic; xf: in std_logic; xs: in std_logic; co3:out std_logic; d1,d2,d3:in std_logic_vector(7 downto 0); qh1,ql1,qh2,ql2,qh3,ql3:out std_logic_vector(3 downto 0);end counter;architecture rt1 of counter iscomponent cnt2port(clr:in std_logic; clk:in std_logic; cnt:buffer std_logic);end component;component d_ffport(d:std_logic; clk:std_logic; q:out std_logic);end component;component mux21port(a,b,s:in std_logic; y:out std_logic);end component;component con24v port(clk,en,clr,ld:in std_logic; d:in std_logic_vector(7 downto 0); co:out std_logic; qh,ql :buffer std_logic_vector(3 downto 0);end component;component con60v port(clk,en,clr,ld:in std_logic; d:in std_logic_vector(7 downto 0); co:out std_logic; qh,ql:buffer std_logic_vector(3 downto 0);end component;component and21port(a,b:in std_logic; y:out std_logic);end component;signal vcc,cnt,q1,q2:std_logic;signal y1_mux21,y_and,y2_mux21,co1,co2:std_logic; signal qh1_con60v,ql1_con60v,qh2_con60v:std_logic_vector(3 downto 0);signal ql2_con60v,qh3_con24v,ql3_con24v:std_logic_vector(3 downto 0);beginvcc=1; comp1:cnt2 port map(vcc,clk,cnt);comp2:d_ff port map(xf,clk,q1);comp3:d_ff port map(xs,clk,q2);comp4:mux21 port map(vcc,co1,q1,y1_mux21); comp5:and21 port map(co1,co2,y_and);comp6:mux21 port map(vcc,y_and,q2,y2_mux21);comp7:con60v port map(cnt,vcc,vcc,vcc,d1,co1,qh1_con60v,ql1_con60v);qh1=qh1_con60v; ql1=ql1_con60v;comp8:con60v port map(cnt,y1_mux21,vcc,vcc,d2,co2,qh2_con60v,ql2_con60v);qh2=qh2_con60v; ql2=ql2_con60v;comp9:con24v port map(cnt,y2_mux21,vcc,vcc,d3,co3,qh3_con24v,ql3_con24v);qh3=qh3_con24v; ql3=ql3_con24v;end rt1;-cnt21library ieee;use ieee.std_logic_1164.all;entity cnt2 isport(clr:in std_logic; clk:in std_logic; cnt:buffer std_logic);end cnt2;architecture one of cnt2 isbeginprocess(clr,clk)beginif(clr=0) then cnt=1;elsif(clkevent and clk=0) thenif(cnt=1) then cnt=0;else cnt=1;end if;end if;end process;end one;configuration con_cnt2 of cnt2 isfor oneend for;end con_cnt2;-cnt2-con24vlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity con24v isport(clk:in std_logic; en:in std_logic; clr:in std_logic; ld:in std_logic; d:in std_logic_vector(7 downto 0); co:out std_logic; qh:buffer std_logic_vector(3 downto 0); ql:buffer std_logic_vector(3 downto 0);end con24v;architecture bhv1 of con24v isbeginco=1 when (qh=0010and ql=0011 and en=1) else 0;process(clk,clr,ld)beginif(clr=0) thenqh=0000;ql=0000;elsif(clkevent and clk=1) thenif(ld=0) thenqh=d(7 downto 4);ql=d(3 downto 0);elsif(en=1) thenif(qh=0010 and ql=0011) thenql=0000;qh=0000;elseql=ql+1;if(ql9) thenql=ql+1;else ql=0000;if(qh2) then qh=qh+1;else qh=0000;end if;end if;end if;end if;end if;end process;end bhv1;configuration con_con24v of con24v isfor bhv1end for;end con_con24v;-con24v-con60vlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity con60v isport(clk:in std_logic; en:in std_logic; clr:in std_logic; ld:in std_logic; d:in std_logic_vector(7 downto 0); co:out std_logic; qh:buffer std_logic_vector(3 downto 0); ql:buffer std_logic_vector(3 downto 0);end con60v;architecture bhv2 of con60v isbeginco=1when(qh=0101and ql=1001and en=1)else 0;process(clk,clr,ld)beginif(clr=0) thenqh=0000;ql=0000;elsif(clkevent and clk=1) thenif(ld=0) thenqh=d(7 downto 0);ql=d(3 downto 0);elsif(en=1) thenif(ql9)then ql=ql+1;else ql=0000;if(qh5) then qh=qh+1;else qh=0000; end if;end if;end if;end if;end process;end bhv2;configuration con_con60v of con60v isfor bhv2end for;end con_con60v;-con60v-d_fflibrary ieee;use ieee.std_logic_1164.all;entity d_ff isport(d:in std_logic; clk:in std_logic; q:out std_logic);end d_ff;architecture bhv3 of d_ff isbeginprocess(clk)beginif(clkevent and clk=1) then q=d;end if;end process;end bhv3;configuration con_d_ff of d_ff isfor bhv3end for;end con_d_ff;-d_ff-mux21library ieee;use ieee.std_logic_1164.all;entity m

温馨提示

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

评论

0/150

提交评论