EDA计数器设计_第1页
EDA计数器设计_第2页
EDA计数器设计_第3页
EDA计数器设计_第4页
EDA计数器设计_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、EDA实验报告EDA多功能数字时钟设计摘要:本实验中我们运用EDA课程中所学的知识,设计了一个拥有时间校正和闹钟功能的24小时制多功能数字时钟。通过本实验,我们初步了解EDA的设计过程;初步掌握用VHDL语言的设计方法和设计思想;初步熟悉Max+Plus II软件平台的编程和仿真,并通过AEDK-EDA实验板下载模拟实现初步了解了硬件实现的方法。关键词:数字时钟、VHDL、FPGA、Max+Plus II一、 设计方案1.功能描述本次设计的多功能数字钟具有基本的计时功能和时间校正功能,同时可以进行定时闹铃。计时功能采用24小时计时,显示时、分、秒。其中分钟和秒模块采用60进制实现;小时设计了2

2、4进制的计数器.时间校正部分,分为时校时和分校时,分别通过控制时校正按钮和分校正按钮来实现.闹铃部分,先通过模式切换按钮进入闹钟定时,然后通过与时间校正相同的方法来进行闹铃时间的预置,当预置到达时间时,时钟将通过蜂鸣器进行闹铃。2.硬件使用模块:  EPF10K20TC144-4,模块10(蜂鸣器),模块17(脉冲源),模块21(开关设置),模块22(设置跳接模块), 模块23(键盘显示模块) 显示/校正时间输出3.VHDL程序设计框图 闹铃按钮(模式切换/校正定时部分选择)数码管选通和显示模六计数,输出数码管选通信号闹钟定时时间输出二、 VHDL源程序library ieee;us

3、e ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity clock isport(clk:in std_logic;-时钟脉冲clk1:in std_logic;-数码管选通时钟脉冲 md1:in std_logic;-模式选择:0为计时,1为闹钟 md2:in std_logic_vector(1 downto 0);-10为时校正(定时),01为分校正(定时) speak:out std_logic;-闹钟 0dout:out std_logic_vector(6 downto 0);-数码管七段码输出 selout

4、:out std_logic_vector(2 downto 0);-数码管选通输出end clock;architecture one of clock issignal sel:std_logic_vector(2 downto 0);-模6计数信号(数码管选通输入)signal hou1:std_logic_vector(3 downto 0);-小时十位signal hou2:std_logic_vector(3 downto 0);-小时个位signal min1:std_logic_vector(3 downto 0);-分钟十位signal min2:std_logic_vect

5、or(3 downto 0);-分钟个位signal seth1:std_logic_vector(3 downto 0);-定时小时十位signal seth2:std_logic_vector(3 downto 0);-定时小时个位signal setm1:std_logic_vector(3 downto 0);-定时分钟十位signal setm2:std_logic_vector(3 downto 0);-定时分钟个位signal sec1:std_logic_vector(3 downto 0);-秒十位signal sec2:std_logic_vector(3 downto 0

6、);-秒个位signal h1:std_logic_vector(3 downto 0); -输出小时十位signal h2:std_logic_vector(3 downto 0); -输出小时个位signal m1:std_logic_vector(3 downto 0); -输出分钟十位signal m2:std_logic_vector(3 downto 0); -输出分钟个位signal s1:std_logic_vector(3 downto 0); -输出秒十位signal s2:std_logic_vector(3 downto 0); -输出秒个位-begin-模6计数(数码

7、管选通)choice:process(clk1)beginif clk1'event and clk1='1' then if sel="101" then sel<="000" else sel<=sel+1; end if;end if;end process choice;selout<=sel;-小时十位h110:process(clk,hou2,min1,min2,sec1,sec2,md1,md2)beginif clk'event and clk='1' then if (h

8、ou1="0010" and hou2="0011")and(min1="0101" and min2="1001") and (sec1="0101" and sec2="1001") then hou1<="0000" elsif hou1="0010"and hou2="0011"and md1='0' and md2="10" then hou1<="

9、0000"elsif (hou2="1001"and(min1="0101" and min2="1001") and (sec1="0101" and sec2="1001")or (hou2="1001"and md1='0' and md2="10") then hou1<=hou1+1; end if;end if;end process h110;-小时个位h220:process(clk,min1,min2,se

10、c1,sec2,md1,md2,hou1)beginif clk'event and clk='1' then if (hou1="0010" and hou2="0011")and(min1="0101" and min2="1001") and (sec1="0101" and sec2="1001") then hou2<="0000" elsif hou2="1001"and(min1="

11、0101" and min2="1001") and (sec1="0101" and sec2="1001") then hou2<="0000" elsif (hou2="1001"and md1='0' and md2="10")or (hou1="0010"and hou2="0011"and md1='0' and md2="10") then hou2<

12、;="0000" elsif (min1="0101" and min2="1001") and (sec1="0101" and sec2="1001")or(md1='0' and md2="10") then hou2<=hou2+1; end if;end if;end process h220;-分钟十位m110:process(clk,min2,sec1,sec2,md1,md2)beginif clk'event and clk=&

13、#39;1' then if (min1="0101" and min2="1001") and (sec1="0101" and sec2="1001") then min1<="0000" elsif min1="0101"and min2="1001"and (md1='0' and md2="01")then min1<="0000" elsif (min2="1

14、001"and (sec1="0101" and sec2="1001") or (min2="1001"and md1='0' and md2="01")then min1<=min1+1; end if;end if;end process m110;-分钟个位m220:process(clk,sec1,sec2,md1,md2)beginif clk'event and clk='1' then if min2="1001"and (

15、sec1="0101" and sec2="1001")then min2<="0000" elsif min2="1001"and (md1='0' and md2="01")then min2<="0000" elsif (sec1="0101" and sec2="1001") or(md1='0' and md2="01")then min2<=min2+1;

16、 end if;end if;end process m220;-秒十位s110:process(clk,sec1,sec2)beginif clk'event and clk='1' then if (sec1="0101" and sec2="1001")then sec1<="0000" elsif sec2="1001"then sec1<=sec1+1; end if;end if;end process s110;-秒个位s220:process(clk,sec2)b

17、eginif clk'event and clk='1' then if sec2="1001" then sec2<="0000" else sec2<=sec2+1; end if; end if;end process s220;-时间设置小时部分sethour1:process(clk,seth2)beginif clk'event and clk='1' then if seth1="0010"and seth2="0011" then seth

18、1<="0000" elsif seth2="1001" then seth1<=seth1+1; end if;end if;end process sethour1;-sethour2:process(clk,md1,md2,seth1)beginif clk'event and clk='1' then if (seth1="0010"and seth2="0011")or seth2="1001"then seth2<="0000&qu

19、ot; elsif md1='1' and md2="10" then eth2<=seth2+1; end if;end if;end process sethour2;-时间设置分钟部分setmin1:process(clk,setm1,setm2)beginif clk'event and clk='1' then if setm1="0101"and setm2="1001"then setm1<="0000" elsif setm2="1001

20、"then setm1<=setm1+1; end if;end if;end process setmin1;-setmin2:process(clk,md1,md2,setm2)beginif clk'event and clk='1'then if setm2="1001"then setm2<="0000" elsif md1='1' and md2="01"then setm2<=setm2+1; end if;end if;end process setm

21、in2;-闹铃speaker:process(clk1,hou1,hou2,min1,min2)beginif clk1'event and clk1='1'then if seth1=hou1 and seth2=hou2 and setm1=min1 and setm2=min2 then if(sec2="0000"or sec2="0010" or sec2="0100" or sec2="0110" or sec2="1000" )then speak<=

22、'1' else speak<='0' end if; end if; end if;end process speaker;-数码管显示disp:process(sel,md1,hou1,hou2,min1,min2,sec1,sec2,seth1,seth2,setm1,setm2)beginif sel="101" then case h1 is when "0000"=>dout<="0111111" when "0001"=>dout<=&qu

23、ot;0000110" when "0010"=>dout<="1011011" when others =>dout<="1000000" end case;elsif sel="100" then case h2 is when "0000"=>dout<="0111111" when "0001"=>dout<="0000110" when "0010"

24、=>dout<="1011011" when "0011"=>dout<="1001111" when "0100"=>dout<="1100110" when "0101"=>dout<="1101101" when "0110"=>dout<="1111101" when "0111"=>dout<="00001

25、11" when "1000"=>dout<="1111111" when "1001"=>dout<="1101111" when others=>dout<="1000000" end case;elsif sel="011" then case m1 is when "0000"=>dout<="0111111" when "0001"=>dout

26、<="0000110" when "0010"=>dout<="1011011" when "0011"=>dout<="1001111" when "0100"=>dout<="1100110" when "0101"=>dout<="1101101" when others=>dout<="1000000" end case;

27、elsif sel="010" then case m2 is when "0000"=>dout<="0111111" when "0001"=>dout<="0000110" when "0010"=>dout<="1011011" when "0011"=>dout<="1001111" when "0100"=>dout<=&qu

28、ot;1100110" when "0101"=>dout<="1101101" when "0110"=>dout<="1111101" when "0111"=>dout<="0000111" when "1000"=>dout<="1111111" when "1001"=>dout<="1101111" when oth

29、ers=>dout<="1000000" end case; elsif sel="001" then case s1 is when "0000"=>dout<="0111111" when "0001"=>dout<="0000110" when "0010"=>dout<="1011011" when "0011"=>dout<="10011

30、11" when "0100"=>dout<="1100110" when "0101"=>dout<="1101101" when others=>dout<="1000000" end case; elsif sel="000" then case s2 is when "0000"=>dout<="0111111" when "0001"=>dou

31、t<="0000110" when "0010"=>dout<="1011011" when "0011"=>dout<="1001111" when "0100"=>dout<="1100110" when "0101"=>dout<="1101101" when "0110"=>dout<="1111101" when "0111"=>

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论