版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、2021/6/71 电子时钟设计电子时钟设计 2021/6/72 设计要求 n设计一个电子时钟。 n要求可以显示时、分、秒。 n用户可以设置时间。 2021/6/73 系统组成 系统可以分为以下模块: n1. 10进制可预置计数器模块 n2. 6进制可预置计数器模块 n3. 24进制可预置计数器模块 n4. LED译码模块 2021/6/74 系统组成方框图 置数按键 控制按键 基准时钟 计数器 动态 显示 译码 显 示 2021/6/75 1. 10进制可预置计数器模块 n时钟由时、分、秒组成,分、秒都为60 进制。 n由于需要使用LED显示时间,所以采用 的计数器应该是10进制的,从而方便
2、译 码模块的通用。 n而60进制计数器可以由10进制计数器 和6进制计数器组成。 2021/6/76 2. 6进制可预置计数器模块 n要组成一个可预置的60进制计数器,还 需要一个6进制的计数器, n使用10进制的进位作为6进制的计数器 的时钟信号可以组成一个60进制的计数 器。 2021/6/77 24进制可预置计数器模块 n时钟的小时是24进制的,所以必须设计 一个24进制的可预置计数器。 n显然,24进制计数器不可以使用6进制计 数器和4进制计数器组成, n因为这样做的24进制计数器将给译码带 来麻烦。 2021/6/78 4. 译码显示模块 n一共有6个LED需要显示,所以需要6个译
3、码模块。 2021/6/79 电子时钟设计与仿真 2021/6/710 10进制计数器VHDL程序 n-文件名:counter10.vhd。 n-功能:10进制计数器,有进位C n-最后修改日期:2004.3.20 nlibrary IEEE; nuse IEEE.STD_LOGIC_1164.ALL; nuse IEEE.STD_LOGIC_ARITH.ALL; nuse IEEE.STD_LOGIC_UNSIGNED.ALL; nentity counter10 is n Port ( clk : in std_logic; n reset : in std_logic; n din :
4、in std_logic_vector(3 downto 0); n dout : out std_logic_vector(3 downto 0); n c:out std_logic); nend counter10; narchitecture Behavioral of counter10 is n signal count : std_logic_vector(3 downto 0); 2021/6/711 nbegin n dout = count; nprocess(clk,reset,din) nbegin n if reset=0then count = din ; c=0;
5、 n elsif rising_edge(clk) then n if count = 1001 then count = 0000; c=1; n else count = count+1; c=0; n end if; n end if; n end process; nend Behavioral; 2021/6/712 10进制计数器仿真 2021/6/713 6进制计数器VHDL程序 n-文件名:counter6.vhd。 n-功能:6进制计数器,有进位C n-最后修改日期:2004.3.20 nlibrary IEEE; nuse IEEE.STD_LOGIC_1164.ALL;
6、nuse IEEE.STD_LOGIC_ARITH.ALL; nuse IEEE.STD_LOGIC_UNSIGNED.ALL; nentity counter6 is n Port ( clk : in std_logic; n reset : in std_logic; n din : in std_logic_vector(2 downto 0); n dout : out std_logic_vector(2 downto 0); n c:out std_logic); nend counter6; narchitecture Behavioral of counter6 is nsi
7、gnal count : std_logic_vector(2 downto 0); nbegin n 2021/6/714 nprocess(clk,reset,din) nbegin n if reset= 0 then count = din; c=0; n elsif rising_edge(clk) then n if count=101 then count=000; c=1; n else count=count+1; c=0; n end if; n end if; nend process; ndout = count; nend Behavioral; 2021/6/715
8、 6进制计数器仿真 2021/6/716 24进制计数器VHDL程序 n-文件名:counter24.vhd。 n-功能:24进制计数器。 n-最后修改日期:2004.3.20 nlibrary IEEE; nuse IEEE.STD_LOGIC_1164.ALL; nuse IEEE.STD_LOGIC_ARITH.ALL; nuse IEEE.STD_LOGIC_UNSIGNED.ALL; nentity counter24 is n Port ( clk : in std_logic; n reset : in std_logic; n din : in std_logic_vector
9、(5 downto 0); n dout : out std_logic_vector(5 downto 0); nend counter24; narchitecture Behavioral of counter24 is nsignal count : std_logic_vector(5 downto 0); nbegin 2021/6/717 nprocess(clk,reset,din) nbegin n if reset= 0 then count = din; n elsif rising_edge(clk) then n if count(3 downto 0)=1001 t
10、hen count(3 downto 0)=0000; ncount(5 downto 4)=count(5 downto 4) +1; n else count(3 downto 0)=count(3 downto 0)+1; n end if; n if count=100011 then count=000000; n end if; n end if; nend process; ndout dout dout dout dout dout dout dout dout dout dout dout=1111111; nend case; nend process; nend Beha
11、vioral; 2021/6/721 顶层设计VHDL程序 n-文件名:clock.vhd。 n-功能:时钟的顶层设计。 n-最后修改日期:2004.3.20 nlibrary IEEE; nuse IEEE.STD_LOGIC_1164.ALL; nuse IEEE.STD_LOGIC_ARITH.ALL; nuse IEEE.STD_LOGIC_UNSIGNED.ALL; nentity clock is n Port ( clk : in std_logic; -1Hz n reset : in std_logic; -复位信号 n dins : in std_logic_vector(
12、6 downto 0);-秒钟预置 n dinm : in std_logic_vector(6 downto 0);-分钟预置 n dinh : in std_logic_vector(5 downto 0);-时钟预置 n secondl: out std_logic_vector(6 downto 0);-秒钟低位输出 n secondh: out std_logic_vector(6 downto 0); -秒钟高位输出 n minutel: out std_logic_vector(6 downto 0); -分钟低位输出 n minuteh: out std_logic_vecto
13、r(6 downto 0); -分钟高位输出 n 2021/6/722 n hourl: out std_logic_vector(6 downto 0); -小时低位输出 n hourh: out std_logic_vector(6 downto 0); -小时高位输出 nend clock; narchitecture Behavioral of clock is ncomponent counter10 is nPort ( clk : in std_logic; n reset : in std_logic; n din : in std_logic_vector(3 downto
14、0); n dout : out std_logic_vector(3 downto 0); n c:out std_logic); nend component; ncomponent counter6 is nPort ( clk : in std_logic; n reset : in std_logic; n din : in std_logic_vector(2 downto 0); n dout : out std_logic_vector(2 downto 0); n c:out std_logic); nend component; ncomponent counter24 i
15、s n Port ( clk : in std_logic; n reset : in std_logic; n din : in std_logic_vector(5 downto 0); n dout : out std_logic_vector(5 downto 0); nend component; n 2021/6/723 ncomponent decoder is nPort (din:in std_logic_vector(3 downto 0 ); n dout:out std_logic_vector(6 downto 0); nend component; nsignal
16、c1,c2,c3,c4:std_logic; nsignal doutsl,doutml:std_logic_vector(3 downto 0); nsignal doutsh,doutmh:std_logic_vector(2 downto 0); nsignal douth:std_logic_vector(5 downto 0); nsignal rdoutsh,rdoutmh:std_logic_vector(3 downto 0); nsignal rdouth:std_logic_vector(7 downto 0); nbegin nrdoutsh = 0 -将秒钟高位数据变为
17、4位,再进行译码 nrdoutmh = 0 -将分钟高位数据变为4位,再进行译码 nrdouth clk,reset=reset, n din=dins(3 downto 0),dout=doutsl,c=c1); n u2: counter6 port map( clk=c1,reset=reset, n din=dins(6 downto 4), dout=doutsh,c=c2); n u3: counter10 port map(clk=c2,reset=reset, din=dinm(3 downto 0), ndout=doutml,c=c3); n u4: counter6 po
18、rt map( clk=c3,reset=reset, n din=dinm(6 downto 4), dout=doutmh, c=c4); n 2021/6/724 nu5: counter24 port map( clk=c4,reset=reset, n din=dinh,dout=douth); nu6: decoder port map( din = doutsl,dout = secondl); -秒的低位 nu7: decoder port map( din = rdoutsh,dout = secondh); -秒的高位 nu8: decoder port map( din = doutml,dout
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年丹寨县人民法院公开招聘司法辅助人员备考题库有答案详解
- 期末综合复习(选择题答题技巧+必刷60题)七年级上学期道德与法治期末复习【含答案详解】
- 国家司法考试卷二刑法(刑罚执行、刑罚消灭)模拟试卷1
- 精确制导技术
- 健康教育科室在健康扶贫中的经验总结
- 健康城市建设的健康治理政策创新
- 粮食安全执法培训课件
- CT仿真内镜在结直肠癌手术前评估中的意义
- 2026年内蒙古科技职业学院单招综合素质考试备考试题带答案解析
- 2026年南平市公安局莒口派出所招聘工作备考题库有答案详解
- 肿瘤化疗导致的中性粒细胞减少诊治中国专家共识解读
- 2025年查对制度考核考试题库(答案+解析)
- 云南省2025年普通高中学业水平合格性考试历史试题
- 骨关节疾病危害课件
- 《再见2025欢迎2026》迎新年元旦主题班会
- 猫屎咖啡介绍
- DB54T 0540-2025 区域性强降雨气象评估标准
- 2025-2026 学年三年级 道德与法治 随堂检测 试卷及答案
- 广西贵百河2025-2026学年高一上学期12月联考语文试题
- 《手术室护理实践指南(2025版)》
- 四川省2025年高职单招职业技能综合测试(中职类)汽车类试卷(含答案解析)
评论
0/150
提交评论