实验6_电子时钟设计说明

上传人:xmg****18 文档编号:113736040 上传时间:2019-11-09 格式:PPT 页数:26 大小:749KB
返回 下载 相关 举报
实验6_电子时钟设计说明_第1页
第1页 / 共26页
实验6_电子时钟设计说明_第2页
第2页 / 共26页
实验6_电子时钟设计说明_第3页
第3页 / 共26页
实验6_电子时钟设计说明_第4页
第4页 / 共26页
实验6_电子时钟设计说明_第5页
第5页 / 共26页
点击查看更多>>
资源描述

《实验6_电子时钟设计说明》由会员分享,可在线阅读,更多相关《实验6_电子时钟设计说明(26页珍藏版)》请在金锄头文库上搜索。

1、8.20 电子时钟设计,设计要求,设计一个电子时钟。 要求可以显示时、分、秒。 用户可以设置时间。,系统组成,系统可以分为以下模块: 1. 10进制可预置计数器模块 2. 6进制可预置计数器模块 3. 24进制可预置计数器模块 4. LED译码模块,系统组成方框图,1. 10进制可预置计数器模块,时钟由时、分、秒组成,分、秒都为60进制。 由于需要使用LED显示时间,所以采用的计数器应该是10进制的,从而方便译码模块的通用。 而60进制计数器可以由10进制计数器和6进制计数器组成。,2. 6进制可预置计数器模块,要组成一个可预置的60进制计数器,还需要一个6进制的计数器, 使用10进制的进位作

2、为6进制的计数器的时钟信号可以组成一个60进制的计数器。,24进制可预置计数器模块,时钟的小时是24进制的,所以必须设计一个24进制的可预置计数器。 显然,24进制计数器不可以使用6进制计数器和4进制计数器组成, 因为这样做的24进制计数器将给译码带来麻烦。,4. 译码显示模块,一共有6个LED需要显示,所以需要6个译码模块。,电子时钟设计与仿真,10进制计数器VHDL程序,-文件名:counter10.vhd。 -功能:10进制计数器,有进位C -最后修改日期:2004.3.20 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_

3、LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity counter10 is Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(3 downto 0); dout : out std_logic_vector(3 downto 0); c:out std_logic); end counter10; architecture Behavioral of counter10 is signal count : std_logic_vec

4、tor(3 downto 0);,begin dout = count; process(clk,reset,din) begin if reset=0then count = din ; c=0; elsif rising_edge(clk) then if count = “1001“ then count = “0000“; c=1; else count = count+1; c=0; end if; end if; end process; end Behavioral;,10进制计数器仿真,6进制计数器VHDL程序,-文件名:counter6.vhd。 -功能:6进制计数器,有进位

5、C -最后修改日期:2004.3.20 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity counter6 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 coun

6、ter6; architecture Behavioral of counter6 is signal count : std_logic_vector(2 downto 0); begin,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; dout = count; end Be

7、havioral;,6进制计数器仿真,24进制计数器VHDL程序,-文件名:counter24.vhd。 -功能:24进制计数器。 -最后修改日期:2004.3.20 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity counter24 is Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(5 downto 0); do

8、ut : out std_logic_vector(5 downto 0); end counter24; architecture Behavioral of counter24 is signal count : std_logic_vector(5 downto 0); begin,process(clk,reset,din) begin if reset= 0 then count = din; elsif rising_edge(clk) then if count(3 downto 0)=“1001“ then count(3 downto 0)=“0000“; count(5 d

9、ownto 4)=count(5 downto 4) +1; else count(3 downto 0)=count(3 downto 0)+1; end if; if count=“100011“ then count=“000000“; end if; end if; end process; dout = count; end Behavioral;,24进制计数器仿真,译码器VHDL程序,-文件名:decoder.vhd。 -功能:将4bit二进制数译码,在LED上显示相应数字。 -最后修改日期:2004.3.20 library IEEE; use IEEE.STD_LOGIC_1

10、164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity decoder is Port (din:in std_logic_vector(3 downto 0 ); -四位二进制码输入 dout:out std_logic_vector(6 downto 0) ); -输出LED七段码 end decoder; architecture Behavioral of decoder is begin,process(din) begin case din is when “0000“ = dou

11、t dout dout dout dout dout dout dout dout dout dout=“1111111“; end case; end process; end Behavioral;,顶层设计VHDL程序,-文件名:clock.vhd。 -功能:时钟的顶层设计。 -最后修改日期:2004.3.20 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity clock is Port ( clk : in st

12、d_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: out std_logic

13、_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; architecture Behavioral of clock is component counter10 is Port ( clk : in std_logic; reset : in std_logic; din

14、 : in std_logic_vector(3 downto 0); dout : out std_logic_vector(3 downto 0); c:out std_logic); end component; component counter6 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 component; compon

15、ent counter24 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 decoder is Port (din:in std_logic_vector(3 downto 0 ); dout:out std_logic_vector(6 downto 0); end component; signal c1,c2,c3,c4:s

16、td_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(7 downto 0); begin rdoutsh clk,reset=reset, din=dins(3 downto 0),dout=doutsl,c=c1); u2: counter6 port map( clk=c1,reset=reset, din=dins(6 downto 4), dout=doutsh,c=c2); u3: counter10 port m

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号