




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 数电课程设计 系:.电子信息与计算机科学系 . 专业:. 自动化 .班级:. 文自112-2班 . 姓名:. 桑*超 . 学号:. 2011905192* .数字逻辑与数字系统课程设计24小时制时钟一、实验目的:1了解多功能数字电子钟的工作原理。2 学习数字系统设计中自顶向下的设计方法。3加深利用EDA技术实现数字系统的体会。实验结果基本要求:1、能够正确的连线及下载。2、能够完成以秒为最小及时单位的时钟设计。3、时钟能够正常调整时、分、秒的时间。扩展部分:· 能够完成整点报时的功能。· 能够完成预设闹钟的功能。二、基本功能图:正常的计时功能正常的调时功能正常的显示功能扩
2、展功能图:整点报时功能闹钟定时功能3、整体上有几个模块计时功能模块:它是由两个60进制计数器和一个24进制计数器连接成的。构成了时钟正常的计时功能。当到达59秒钟的时候,当再来一个CP脉冲的时候,将自动进位,使分针上加一。分针也是一样。当时针到达23点59分59秒的时候,当再次来一个CP脉冲时候,又转化为0点0分0秒。调时功能模块:调分有效时,按动分钟调节键,分针加一;调时有效,按动小时调节键,时针加一。整点报时与闹钟功能模块:时间每走到一个整点,蜂鸣器发出响声;扩展部分可以按预定的时间让蜂鸣器鸣叫。在闹钟定时显示状态下,按下set键,进入闹钟的“时”设置状态,之后按下闹钟的k键,进入闹钟的分
3、设置状态,再按下k键进入秒设置状态,再次按下k键,又回到闹钟的定时显示状态。三、各模块程序、符号图、仿真图模块一:24进制library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity v_cnt24 isport(clk,en,reset:instd_logic;ql,qh:buffer std_logic_vector(3 downto 0);co: outstd_logic );end v_cnt24 ;architecture one
4、 of v_cnt24 isbeginco<='1' when(ql="0011"and qh="0010"and en='1') else '0' ;process (clk,reset)beginif(reset='0')thenql<="0000"qh<="0000"else if(clk'event and clk='1' ) then if( en='1')thenif(ql=&quo
5、t;0011"and qh="0010") thenql<="0000"qh<="0000"elsif(ql="1001") thenql<="0000"qh<=qh+'1' else ql<=ql+'1' end if; end if;end if; end if ;end process; end one ;模块二:60进制library ieee;use ieee.std_logic_1164.all;use ieee
6、.std_logic_unsigned.all;entity v_cnt60 isport(clk,reset,en:instd_logic;ql,qh:bufferstd_logic_vector(3 downto 0);co:outstd_logic);end v_cnt60;architecture one of v_cnt60 isbeginco<='1' when (ql="1001" and qh="0101" and en='1' ) else'0'process(clk,reset)b
7、eginif(reset='0') then ql<="0000"qh<="0000"elsif (clk'event and clk='1')thenif(ql="1001"and qh="0101")thenql<="0000"qh<="0000"elsif(ql="1001")thenql<="0000"qh<=qh+1;elseql<=ql+1;e
8、nd if ;end if;end process ;end one;模块三:二选一选择器;当sel=1时,选择输出a,否则输出b。library ieee;use ieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entity v_mux2_1 isport(sel:instd_logic;a,b:instd_logic;y:outstd_logic);end v_mux2_1 ;architecture one of v_mux2_1 isbeginprocess(sel,a,b)beginif (sel='1')
9、theny<=a;else y<=b;end if;end process;end one;模块四:时钟计时器:有两个六十进制计数器分别作为秒和分;一个二十四进制作为小时构成时钟计数器。css是调秒功能,cms是调分功能,chs是调时功能,clk1HZ是计时脉冲,clk4HZ是调时脉冲。闹钟计时器原理同时钟计时器。例化后:时钟计时器 闹钟计时器 模块五:八选一数据选择器: sel是(三位二进制)选择输入端,当选择输入端从“000”“111”变化时,Y对应选择输出D0D7.library ieee;use ieee.std_logic_1164.all;use ieee.std_lo
10、gic_unsigned.all;use ieee.std_logic_arith.all;entity mux48 isport(sel: in std_logic_vector(2 downto 0); d0,d1,d2,d3,d4,d5,d6,d7: in std_logic_vector(3 downto 0); y : out std_logic_vector(3 downto 0);end mux48;architecture behavor of mux48 issignal dout :std_logic_vector(3 downto 0);beginprocess(sel)
11、 begin case sel is when"000"=>dout<=d0; when"001"=>dout<=d1; when"010"=>dout<=d2; when"011"=>dout<=d3; when"100"=>dout<=d4; when"101"=>dout<=d5; when"110"=>dout<=d6; when others=>dout&l
12、t;=d7; end case; end process; y<=dout;end behavor;模块六:7段示波显示器:根据输入端输入“000”“111”,根据示波显示器a-g端进行编码,对应输出0-9 显示器:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity v_deco74 isport(a:instd_logic_vector(3 downto 0);b:outstd_logic_vector(6 downto 0);end v_deco74;architecture
13、one of v_deco74 isbeginprocess(a)begincase a is when "0000"=>b<="1111110"when "0001"=>b<="0110000"when "0010"=>b<="1101101"when "0011"=>b<="1111001"when "0100"=>b<="0110011&qu
14、ot;when "0101"=>b<="1011011"when "0110"=>b<="1011111"when "0111"=>b<="1110000"when "1000"=>b<="1111111"when "1001"=>b<="1111011"when "1010"=>b<="0000
15、001"when others =>b<="XXXXXXX"end case;end process;end one;模块七:八进制计数器:当(清零端)reset为0时,计数端自动清零; reset不为零时,每遇一个时钟脉冲上升沿时,自动计数一次,计满“111”时,自动清零为“000”,然后从新计数,且co(高位输出端)输出一。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity v_cnt8 isport(clk,reset,en:in std_
16、logic;q:bufferstd_logic_vector(2 downto 0);co:outstd_logic);end v_cnt8;architecture one of v_cnt8 isbeginco<='1' when(q="111" and en='1') else '0' ;process(clk,reset)beginif(reset='0') then q<="000"elsif(clk'event and clk='1') the
17、nif(q="111") then q<="000"elseq<=q+1;end if;end if;end process;end one;模块八:显示器:例化后:由八选一、显示译码器、和八进制计数器组成,八进制作为八选一选择器的选择(sel)端。模块九:时钟、闹钟 二选一选择输出器:当sel=0时,选择输出时钟的高地位(timel、timeh),否则选择输出闹钟的高地位(clerkl、clerkh)。library ieee;use ieee.std_logic_1164.all;useieee.std_logic_unsigned.al
18、l;entity v_mux_tc isport(sel:instd_logic;timel,clerkl:instd_logic_vector(3 downto 0);timeh,clerkh:instd_logic_vector(7 downto 4);l:outstd_logic_vector(3 downto 0);h:outstd_logic_vector(7 downto 4);end v_mux_tc ;architecture one of v_mux_tc isbeginprocess(sel,timel,clerkl,timeh,clerkh)beginif (sel=
19、39;0')thenl<=timel;h<=timeh;else l<=clerkl;h<=clerkh;end if;end process;end one;模块十:报时比较器当en=1时,分别对时钟计时器,闹钟计时器的时、分、秒进行比较,若相同择输出1否则,输出0。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity comp isport(en:instd_logic;tsh,csh,tmh,cmh,thh,chh:instd_logic_vector
20、(7 downto 4);tml,cml,thl,chl:instd_logic_vector(3 downto 0);bell:outstd_logic);end comp;architecture one of comp isbeginprocess(en,tsh,csh,tmh,cmh,thh,chh,tml,cml,thl,chl)beginif(en='1') thenif(thh=chh and thl=chl) thenif(tmh=cmh and tml=cml) thenif(tsh=csh) thenbell<='1'elsebell&
21、lt;='0'end if;end if;end if;end if;end process;end one;模块十一:报时器:当bell=1时,分别秒为0、2、4、6、8时输出clk512;分计时器为59分(tmh=5,tml=9)时,且秒计时器高位为5(tsh=5)时,当秒的低位计时器为3、5、7(tsl=3、5、7)时输出clk512,当秒的低位计时器为9时,输出clk1024。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity baoshi isport(clk5
22、12,clk1024,bell:instd_logic;tsl,tml:instd_logic_vector(3 downto 0);tsh,tmh:instd_logic_vector(7 downto 4);bell:outstd_logic);end baoshiarchitecture one of baoshi isbeginprocess(bell,tsl,tml,tsh,tmh,clk512,clk1024)beginif(tmh="0101" and tml="1001") thenif( tsh="0101") th
23、enif(tsl="0011" or tsl="0101" or tsl="0111") thenbel<=clk512;elsif(tsl="1001") thenbel<=clk1024;end if;end if;end if;if(bell='1') thencase tsl iswhen "0000"=>bel<=clk512;when "0010"=>bel<=clk512;when "0100&quo
24、t;=>bel<=clk512;when "0110"=>bel<=clk512;when "1000"=>bel<=clk512;when others=>null;end case;end if;end process;end one;模块十二:分频器输入一个1024HZ频率的时钟脉冲,通过高分频,分别分出1HZ、2HZ、4HZ、512HZ、1024HZ频率的时钟脉冲。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.al
25、l;use ieee.std_logic_arith.all;entity fenpin isport(reset,clk :in std_logic; clk1024 :out std_logic; clk512,clk4,clk2,clk1 :buffer std_logic);end fenpin;architecture one of fenpin is signal q: std_logic_vector(9 downto 0);begin process (clk,reset)begin if(reset='0')then q<="000000000
26、0" elsif(clk'event and clk='1')then q<=q+1; end if;clk1024<=clk; clk1<=q(9); clk2<=q(8); clk4<=q(7); clk512<=q(0); end process;end one;模块十三:flash闪烁器en=1时,当时钟脉冲clk=1时,输出端YO=SO,Y1=S1,否则输出YO=Y1=1010.library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.
27、all;entity flash isport( en,clk : in std_logic;s0:instd_logic_vector(3 downto 0);s1:instd_logic_vector(7 downto 4);y0:outstd_logic_vector(3 downto 0);y1:outstd_logic_vector(7 downto 4);end flash;architecture one of flash isbeginprocess(en,clk,s0,s1)beginif(en='1') thenif(clk='1') the
28、ny0<=s0;y1<=s1;elsey0<="1010"y1<="1010"end if;elsey0<=s0; y1<=s1;end if;end process;end one;模块十四:控制器clk:时钟脉冲set、k:调节键clr:清零键fh、fm、fs:调时或设置闹钟时分别对应时、分、秒、闪烁cht、cmt、cst:分别对应调时、分、秒chs、cms、css:分别对应调闹钟、分、秒sel_show:为0时选择输出显示时钟,为1时选择输出显示闹钟clk=1上升沿时有效;当clr=0时,回到初始状态s0.状态s
29、0时,如果k=1且set=0,则进入状态s4;如果k=0且set=1,则进入状态s1;否则状态不发生变化。状态1时(chs ='1'、fh='1'),如果k=1 则进入状态s2;否则状态不发生变化。状态2时,(cms='1'、fm='1')如果k=1 则进入状态s3;否则状态不发生变化。状态3时,(css='1'、fs='1')如果k=1 则进入状态s0;否则状态不发生变化。状态4时,(sel_show='1')如果k=1且set='1' 则进入状态s5;否则状态不发
30、生变化。状态5时,(cht='1'、fh='1'、sel_show='1')如果k=1 则进入状态s6;否则状态不发生变化。状态6时,(cmt='1'、fm='1'、sel_show='1')如果k=1 则进入状态s7;否则状态不发生变化。状态7时,(cst='1'、fs='1')如果k=1 则进入状态s0;否则状态不变library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;us
31、e ieee.std_logic_arith.all;entity v_control isport(clk : in std_logic; k,set,clr :in std_logic; fh,fm,fs,sel_show :out std_logic; chs,cht,cms,cmt,css,cst :out std_logic);end v_control;architecture one of v_control is type states is (s0,s1,s2,s3,s4,s5,s6,s7); signal state : states:=s0; beginprocess(c
32、lk,k,set,clr) beginif(clr='0')then state<=s0;elsif (clk'event and clk='1') then case state is when s0=> if(k='1' and set='0')then state<=s4; elsif (k='0' and set='1') then state<=s1; end if;when s1=> if(k='1')then state<=s
33、2; end if;when s2=> if(k='1')then state<=s3;end if;when s3=> if(k='1')then state<=s0; end if;when s4=> if (k='0' and set='1') then state<=s5; end if;when s5=> if(k='1')then state<=s6;end if ;when s6=> if(k='1')then state<=s7;end if;when s7=> if(k='1')thenstate<=s0;end if;end case;end if;end process;-with state select chs <='1' when s1, '0' when others;with state select cms<='1' when s2, '0' when others;with state select css<=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 矿井防灭火技术课件
- 公路工程爆破施工合同范文二零二五年
- 智慧解决方案的市场竞争力
- 二零二五版上海物业管理合同标准范例
- 二零二五版雇佣中介劳动合同
- 二零二五版销售兼职合同
- 二零二五版按揭车辆转让协议书范例
- 景区导游服务规范
- 可回收物仓储行业跨境出海战略研究报告
- 相声表演在线平台企业制定与实施新质生产力战略研究报告
- JJF 2114-2024 矿用二氧化碳气体检测报警器校准规范
- 2024安全生产法律法规知识培训
- 《健康住宅评价标准》
- DB52T 046-2018 贵州省建筑岩土工程技术规范
- 三叉神经病病例分析
- GB/T 19077-2024粒度分析激光衍射法
- (完整版)减数分裂课件
- GB/T 44481-2024建筑消防设施检测技术规范
- 2024年《武器装备科研生产单位保密资格标准》内容考试试题库及答案
- 2024小学语文教学及说课课件:二年级下册《沙滩上的童话》
- 市政道路监理大纲34368
评论
0/150
提交评论