ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:55.12KB ,
资源ID:9699077      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9699077.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(52电子时钟a.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

52电子时钟a.docx

1、52 电子时钟a5.2 电子时钟程序设计与仿真实验1 实验目的设计一个含时/分/秒的电子时钟,并且具有可设置、清除的功能。2 实验原理根据电子时钟设计要求,系统可以分为以下模块:控制模块,基准时钟模块,计数器可预置模块,锁存器模块, LED译码模块,系统组成方框图如图5.2.1所示。图5.2.1 系统组成方框图(1)10进制可预置计数器模块时钟由时、分、秒组成,分、秒都为60进制。由于需要使用LED显示时间,所以采用的计数器应该是10进制的,从而方便译码模块的通用。而60进制计数器可以由10进制计数器和6进制计数器组成。(2)6进制可预置计数器模块要组成一个可预置的60进制计数器,还需要一个6

2、进制的计数器,使用10进制的进位作为6进制的计数器的时钟信号可以组成一个60进制的计数器。(3)24进制可预置计数器模块 时钟的小时是24进制的,所以必须设计一个24进制的可预置计数器。显然,24进制计数器不可以使用6进制计数器和4进制计数器组成,因为这样做的24进制计数器将给译码带来麻烦。(4)译码显示模块一共有6个LED需要显示,所以需要6个译码模块。3 实验内容 (1)由CLK引入1Hz的时钟信号。 (2)由RESET引入总清零信号,dins、dinm、dinh分别引入秒、分、钟可预置信号。 (3)设计一个异步清零六(count6)进制计数器,一个异步清零十(count10)进制计数器和

3、一个二十四(count24)进制计数器。(4) 设计一个BCD码到LED的七段译码器(led7s).(5) 设计一个含时/分/妙的电子时钟。(6)对时钟电路进行下载4 实验预习与思考题(1) 学习用VHDL语言编写十进制,六进制,二十四进制计数器。 (2) 怎样编写秒、分、钟可预置信号。(3) 用十进制和六进制组成六十进制计数器的级联方法。(4) 为什么时钟的二十四进制不用一个六进制和一个四进制组成。5 程序设计与仿真 (1)程序设计十进制计数器(count10.vhd)。十进制计数器源程序如下:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE

4、.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;- Uncomment the following lines to use the declarations that are- provided for instantiating Xilinx primitive components.-library UNISIM;-use UNISIM.VComponents.all;entity count10 is Port ( clk : in std_logic; reset : in std_logic; din : in std_lo

5、gic_vector(3 downto 0); dout : out std_logic_vector(3 downto 0); c:out std_logic);end count10;architecture Behavioral of count10 issignal count : std_logic_vector(3 downto 0);begindout = count;process(clk,reset,din)begin if reset=0then count = din ; c=0; elsif rising_edge(clk) then if count = 1001 t

6、hen count = 0000; c=1; else count = count+1; c=0; end if; end if;end process;六进制计数器(count6.vhd),六进制计数器源程序如下: library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;- Uncomment the following lines to use the declarations that are- provided for instantiat

7、ing Xilinx primitive components.-library UNISIM;-use UNISIM.VComponents.all;entity count6 is Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(2 downto 0); dout : out std_logic_vector(2 downto 0); c:out std_logic);end count6;architecture Behavioral of count6 issignal count :

8、 std_logic_vector(2 downto 0);begindout = count; process(clk,reset,din) begin if reset= 0 then count = din; c=0; elsif rising_edge(clk) then if count=101 then count=000; c=1; else count=count+1; c=0; end if; end if; end process;二十四进制计数器(count24.vhd),二十四进制计数器源程序如下:library IEEE;use IEEE.STD_LOGIC_1164

9、.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;- Uncomment the following lines to use the declarations that are- provided for instantiating Xilinx primitive components.-library UNISIM;-use UNISIM.VComponents.all;entity count24 is Port ( clk : in std_logic; reset : in std_logic; di

10、n : in std_logic_vector(5 downto 0); dout : out std_logic_vector(5 downto 0) );end count24;architecture Behavioral of count24 issignal count : std_logic_vector(5 downto 0);begin dout = count; process(clk,reset,din) begin if reset= 0 then count = din; elsif rising_edge(clk) then if count(3 downto 0)=

11、1001 then count(3 downto 0)=0000; count(5 downto 4)=count(5 downto 4) +1; else count(3 downto 0)=count(3 downto 0)+1; end if; if count=100011 then count dout dout dout dout dout dout dout dout dout dout dout= 0000000;end case;end process;end Behavioral;顶层设计文件(clock_top.vhd,设计的电子时钟可以显示时,分,秒,还可以进行时间的设

12、置和调节。顶层文件VHDL源程序如下:use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;- Uncomment the following lines to use the declarations that are- provided for instantiating Xilinx primitive components.-library UNISIM;-use UNISIM.VComponents.all;entity clock_top is Port (c

13、lk : in std_logic; -1Hz reset : in std_logic; -复位信号 dins : in std_logic_vector(6 downto 0); -秒钟预置 dinm : in std_logic_vector(6 downto 0); -分钟预置 dinh : in std_logic_vector(5 downto 0); -时钟预置 secondl: out std_logic_vector(6 downto 0); -秒钟低位输出 secondh: out std_logic_vector(6 downto 0); -秒钟高位输出 minutel:

14、 out std_logic_vector(6 downto 0); -分钟低位输出 minuteh: out std_logic_vector(6 downto 0); -分钟高位输出 hourl: out std_logic_vector(6 downto 0); -小时低位输出 hourh: out std_logic_vector(6 downto 0); -小时高位输出end clock_top;architecture Behavioral of clock_top iscomponent count10 is Port ( clk : in std_logic; reset :

15、in std_logic; din : in std_logic_vector(3 downto 0); dout : out std_logic_vector(3 downto 0); c:out std_logic);end component;component count6 is Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(2 downto 0); dout : out std_logic_vector(2 downto 0); c:out std_logic);end compo

16、nent;component count24 is Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(5 downto 0); dout : out std_logic_vector(5 downto 0);end component;component led7s is Port (din:in std_logic_vector(3 downto 0 ); dout:out std_logic_vector(6 downto 0); end component;SIGNAL N : STD_L

17、OGIC_VECTOR(24 DOWNTO 0);SIGNAL M : STD_LOGIC;signal c1,c2,c3,c4:std_logic;signal doutsl,doutml:std_logic_vector(3 downto 0);signal doutsh,doutmh:std_logic_vector(2 downto 0);signal douth:std_logic_vector(5 downto 0);signal rdoutsh,rdoutmh:std_logic_vector(3 downto 0); signal rdouth:std_logic_vector

18、(7 downto 0);beginPROCESS(CLK,RESET) BEGIN IF RESET=0 THEN N0); ELSIF(CLKEVENT AND CLK=1)THEN N=N+1; END IF;END PROCESS; M=N(24);rdoutsh = 0&doutsh; -将秒钟高位数据变为4位,再进行译码rdoutmh = 0&doutmh; -将分钟高位数据变为4位,再进行译码rdouth M,reset=reset, din=dins(3 downto 0), dout=doutsl, c=c1);u2: count6 port map( clk=c1,rese

19、t=reset, din=dins(6 downto 4), dout=doutsh, c=c2);u3: count10 port map( clk=c2,reset=reset, din=dinm(3 downto 0), dout=doutml, c=c3); u4: count6 port map( clk=c3,reset=reset, din=dinm(6 downto 4), dout=doutmh, c=c4);u5: count24 port map( clk=c4,reset=reset, din=dinh,dout=douth);u6: led7s port map( d

20、in = doutsl,dout = secondl); -秒的低位u7: led7s port map( din = rdoutsh,dout = secondh); -秒的高位u8: led7s port map( din = doutml,dout = minutel); -分的低位 u9: led7s port map( din = rdoutmh,dout = minuteh); -分的高位u10: led7s port map( din = rdouth(3 downto 0),dout = hourh); -时的低位u11: led7s port map( din = rdout

21、h(7 downto 4),dout = hourl); -时的高位end Behavioral;(2)仿真二十四进制计数器仿真结果如图5.2.2所示。由图知当reset为低电平时清零,为高电平时开始计数,并且计到24。图中dout的输出选择的是无符号整数显示方式, 图5.2.2 二十四进制计数器仿真结果顶层仿真结果如图5.2.3所示,图5.2.3(a)仿真结果可以看到秒的个位和秒的十位之间的进位,图5.2.3(b)的仿真结果可以清楚看到秒的十位向分的个位之间的进位。(a)电子时钟秒的个位和秒的十位之间的进位(b)电子时钟秒的十位向分的个位之间的进位(c)电子时钟仿真局部放大图图5.2.3 电子时钟仿真结果(6)下载 引脚设置和下载请参照第2章的2.2节方法。 6 实验报告(1)用VHDL语言编写电子时钟的源程序。(2)分别将电子时钟中的十进制计数器、六进制计数器及二十四进制计数器进行仿真并分析仿真结果。(3)对电子时钟系统的功能进行仿真并分析仿真结果。(4)写出实验体会。7实验练习题修改本次实验中的程序,使设计的电子时钟为12小时制。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1