版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、电子时钟设计,设计要求,设计一个电子时钟。 要求可以显示时、分、秒。 用户可以设置时间。,系统组成,系统可以分为以下模块: 1. 10进制可预置计数器模块 2. 6进制可预置计数器模块 3. 24进制可预置计数器模块 4. LED译码模块,系统组成方框图,1. 10进制可预置计数器模块,时钟由时、分、秒组成,分、秒都为60进制。 由于需要使用LED显示时间,所以采用的计数器应该是10进制的,从而方便译码模块的通用。 而60进制计数器可以由10进制计数器和6进制计数器组成。,2. 6进制可预置计数器模块,要组成一个可预置的60进制计数器,还需要一个6进制的计数器, 使用10进制的进位作为6进制的
2、计数器的时钟信号可以组成一个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_LOGIC
3、_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_vector(3
4、 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进制计数器,有进位C -最后修改日期
5、: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 counter6; arc
6、hitecture 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 Behavioral;,6进制
7、计数器仿真,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); dout : out std_
8、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 downto 4)=count(5
9、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_1164.ALL; use IEEE.STD
10、_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 = dout dout dout dout dout d
11、out 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 std_logic; -1Hz reset : in
12、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_vector(6 downto 0); -分钟低
13、位输出 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 : in std_logic_vector(3
14、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; component counter24 is Port ( c
15、lk : 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:std_logic; signal doutsl,d
16、outml: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
17、: counter6 port map( clk=c1,reset=reset, din=dins(6 downto 4), dout=doutsh,c=c2); u3: counter10 port map(clk=c2,reset=reset, din=dinm(3 downto 0), dout=doutml,c=c3); u4: counter6 port map( clk=c3,reset=reset, din=dinm(6 downto 4), dout=doutmh, c=c4);,u5: counter24 port map( clk=c4,reset=reset, din=dinh,dout=douth); u6: decoder port map( din = doutsl,dout = secondl); -秒的低位 u7: decoder port map( din = rdoutsh,dout = secondh); -秒的高位 u8:
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 上海农林职业技术学院《档案管理学》2025-2026学年期末试卷
- 上海东海职业技术学院《小儿内科》2025-2026学年期末试卷
- 山西师范大学《保险学》2025-2026学年期末试卷
- 上海立信会计金融学院《模拟导游》2025-2026学年期末试卷
- 上海应用技术大学《运动解剖学》2025-2026学年期末试卷
- 上海东海职业技术学院《新闻编辑》2025-2026学年期末试卷
- 石家庄经济职业学院《国际投资学教程》2025-2026学年期末试卷
- 泰州学院《经济学》2025-2026学年期末试卷
- 沈阳音乐学院《临床药物治疗学》2025-2026学年期末试卷
- 上海浦东职业技术学院《服务市场营销》2025-2026学年期末试卷
- 2026年江苏省常州市中考英语调研试卷
- 2026年licenseout对外授权交易关键条款与谈判要点
- 2026福建浦开集团有限公司、福建浦盛产业发展集团有限公司、福建浦丰乡村发展集团有限公司社会公开招聘补充笔试模拟试题及答案解析
- (一诊)2026年兰州市高三模拟考试政治试卷(含答案)
- 2026年3月各地高三语文开学模拟考13道作文题目及范文汇编
- 财政局国库内部控制制度
- 2026年成都市公安局招聘警务辅助人员笔试试题(含答案)
- 2026秋招:广州环投集团笔试题及答案
- 2026广西来宾市忻城县国鑫商贸有限责任公司招聘财务人员2人考试参考题库及答案解析
- 2026年二氧化碳罐车运输项目评估报告
- 【新教材】人教PEP版(2024)四年级下册英语全册教案(含教学计划)
评论
0/150
提交评论