首页 基于VHDL的数字钟设计及其仿真

基于VHDL的数字钟设计及其仿真

举报
开通vip

基于VHDL的数字钟设计及其仿真基于VHDL的数字钟设计及其仿真 结构化设计 元件例化 配置 原理图 一 引言 所谓数字钟是指利用电子电路构成的计时器,相对机械钟而言,数字钟能达到准确计时,同时能对该种进行调整。当然,在此基础上还能够实现整点报时,定时报闹等功能。 设计过程采用系统设计的方法,先分析任务得到系统要求,然后进行总体设计,划分子系统,然后进行详细设计,决定各个功能子系统的VHDL程序,最后进行调试仿真。 通过此次设计,对基于VHDL的结构化描述有深刻理解,为今后的集成电路设计打下坚实的基础。 二 设计任务和要求 对于时钟...

基于VHDL的数字钟设计及其仿真
基于VHDL的数字钟设计及其仿真 结构化设计 元件例化 配置 原理图 一 引言 所谓数字钟是指利用电子电路构成的计时器,相对机械钟而言,数字钟能达到准确计时,同时能对该种进行调整。当然,在此基础上还能够实现整点报时,定时报闹等功能。 设计过程采用系统设计的方法,先 分析 定性数据统计分析pdf销售业绩分析模板建筑结构震害分析销售进度分析表京东商城竞争战略分析 任务得到系统要求,然后进行总体设计,划分子系统,然后进行详细设计,决定各个功能子系统的VHDL程序,最后进行调试仿真。 通过此次设计,对基于VHDL的结构化描述有深刻理解,为今后的集成电路设计打下坚实的基础。 二 设计任务和要求 对于时钟,最基本的要求应具有时分秒的计数功能。对于秒必须满足每满60s,分要记一个数,并且秒重新从零计起;对于分必须满足60min,小时要记一个数,并且分重新从零计起,对于时满24后也应重新从零计起。此外当数字中走慢或走快时,还应能予以调整。所以要求设计的数字中电路应具有以下功能: 1. 具有十分秒计数功能,并进行十进制数字显示。 2. 能分别进行时分的手动校正。 三 工作原理 时钟信号的频率有振荡器产生,由于技术最小单位为1s,所以时钟信号经分频器后输出频率为1Hz的秒脉冲clk;而校准信号的频率应高于1Hz,若取0.5,则时钟信号经另一个分频器后输出频率为2Hz的校准信号脉冲clk1。 当无校准信号作用,即校分信号xf、校时信号xs为高电平,整个电路处于正常计数的工作状态时分秒计数器采用同步计数方式其时钟脉冲端均接有分频器输出的时钟信号clk.。en为使能端,高电平有效。三个计数器的复位端clr置入数据控制端ld都接高电平,故其置入端d[7…0]失效,且各计数器输出端分别接译码显示电路。 当有校准信号时,不妨假设只有校分信号,即xf=0、xf=1,则在二选一数据选择器的控制下,分计数器的en端将始终接高电平,即分计数器将独立于秒计数器自行独立计数,但其结果仍影响到时计数器,因为此时没有校时信号。同理,当只有校时信号或同时具有校时、校分信号,情况同上述分析一样。 四 各个模块的VHDL仿真图以及计数部分校正仿真图 (图一、无时间调整下数字钟的仿真运行图) (图二、利用xs信号校对时间的小时数的仿真结果图) (图三、利用xf信号校对时间的分钟数的仿真结果图) 六十进制计数电路模块对应的仿真波形如下图所示了,clk为时钟脉冲,clr为复位端,en为使能控制端,ld位并行置数输入端,ql、qh和co分别为六十进制计数器的个位十位和进位输出,由仿真波形可以看出,个位ql每从0—9计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 is port(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 is component cnt2 port(clr:in std_logic; clk:in std_logic; cnt:buffer std_logic); end component; component d_ff port(d:std_logic; clk:std_logic; q:out std_logic); end component; component mux21 port(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 and21 port(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); begin vcc<='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; ----------cnt21 library ieee; use ieee.std_logic_1164.all; entity cnt2 is port(clr:in std_logic; clk:in std_logic; cnt:buffer std_logic); end cnt2; architecture one of cnt2 is begin process(clr,clk) begin if(clr='0') then cnt<='1'; elsif(clk'event and clk='0') then if(cnt='1') then cnt<='0'; else cnt<='1'; end if; end if; end process; end one; configuration con_cnt2 of cnt2 is for one end for; end con_cnt2; --------------cnt2 --------------con24v library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity con24v is port(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 is begin co<='1' when (qh="0010"and ql="0011" and en='1') else '0'; process(clk,clr,ld) begin if(clr='0') then qh<="0000"; ql<="0000"; elsif(clk'event and clk='1') then if(ld='0') then qh<=d(7 downto 4); ql<=d(3 downto 0); elsif(en='1') then if(qh="0010" and ql="0011") then ql<="0000"; qh<="0000"; else ql<=ql+'1'; if(ql<9) then ql<=ql+1; else ql<="0000"; if(qh<2) 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 is for bhv1 end for; end con_con24v; --------------con24v --------------con60v library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity con60v is port(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 is begin co<='1'when(qh="0101"and ql="1001"and en='1')else '0'; process(clk,clr,ld) begin if(clr='0') then qh<="0000"; ql<="0000"; elsif(clk'event and clk='1') then if(ld='0') then qh<=d(7 downto 0); ql<=d(3 downto 0); elsif(en='1') then if(ql<9)then ql<=ql+1; else ql<="0000"; if(qh<5) then qh<=qh+1; else qh<="0000"; end if; end if; end if; end if; end process; end bhv2; configuration con_con60v of con60v is for bhv2 end for; end con_con60v; --------------con60v -------------d_ff library ieee; use ieee.std_logic_1164.all; entity d_ff is port(d:in std_logic; clk:in std_logic; q: out std_logic); end d_ff; architecture bhv3 of d_ff is begin process(clk) begin if(clk'event and clk='1') then q<=d; end if; end process; end bhv3; configuration con_d_ff of d_ff is for bhv3 end for; end con_d_ff; --------------d_ff --------------mux21 library ieee; use ieee.std_logic_1164.all; entity mux21 is port(a,b,s:in std_logic; y:out std_logic); end mux21; architecture bhv4 of mux21 is begin y<=a when s='0' else b; end bhv4; configuration con_mux21 of mux21 is for bhv4 end for; end con_mux21; ------------mux21 --------------and21 library ieee; use ieee.std_logic_1164.all; entity and21 is port(a,b:in std_logic; y:out std_logic); end and21; architecture and21_arch of and21 is begin y<=a and b; end and21_arch; configuration con_and21 of and21 is for and21_arch end for; end con_and21; ----------------and21 六 总结 初级经济法重点总结下载党员个人总结TXt高中句型全总结.doc高中句型全总结.doc理论力学知识点总结pdf 本次通过数字钟实现的例子展现了VHDL在灵活性,层次化设计方法的优点。程序中 设计了五种元件,采用配置的方式分别将其实体和结构体相连结。再通过元件的例化,端口映射把实现数字钟的整个电路图。说明了VHDL语言具有很强的电路描述和建模能力,能从多个层次对数字系统进行建模与描述。 附:数字时钟的的具体电路图
本文档为【基于VHDL的数字钟设计及其仿真】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_037433
暂无简介~
格式:doc
大小:112KB
软件:Word
页数:13
分类:互联网
上传时间:2017-10-13
浏览量:22