VHDL数字秒表设计_第1页
VHDL数字秒表设计_第2页
VHDL数字秒表设计_第3页
VHDL数字秒表设计_第4页
VHDL数字秒表设计_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

1、VHDL数字秒表设计 专 业: 自动化 班级学号: 5090629 姓 名: 刘丹 2011年 6 月14 日VHDL语言课程设计-秒表设计一、设计实验目的:在MAX+plusII软件平台上,熟练运用VHDL语言,完成数字时钟设计的软件编程、编译、综合、仿真,使用EDA实验箱,实现数字秒表的硬件功能。二、设计实验说明及要求:1、数字秒表主要由:分频器、扫描显示译码器、一百进制计数器、六十进制计数器(或十进制计数器与6进制计数器)、十二进制计数器(或二十四进制计数器)电路组成。在整个秒表中最关键的是如何获得一个精确的100HZ计时脉冲,除此之外,数字秒表需有清零控制端,以及启动控制端、保持保持,

2、以便数字时钟能随意停止及启动。2、数字秒表显示由时(12或24进制任选)、分(60进制)、秒(60进制)、百分之一秒(一百进制)组成,利用扫描显示译码电路在八个数码管显示。3、能够完成清零、启动、保持(可以使用键盘或拨码开关置数)功能。4、时、分、秒、百分之一秒显示准确。三、我的设计思路:    1、四个十进制计数器:用来分别对百分之一秒、十分之秒、秒和分进行计数;    2、两个6进制计数器:用来分别对十秒和十分进行计数;3、一个24进制计数器,用来对小时进行计数;    3、分频率器:用来产生100H

3、z的计数脉冲;    4、显示译码器:完成对显示译码的控制。四、设计过程:1.分频器:由10MHz变为100Hz,10MHz的周期是10的(-7)次方,而100Hz的周期是10的(-2)次方,而且方波是高低相间,只有高电平有效,所以100Hz的周期需要取一半,即0.02秒,这样算出的分频倍数就是50000分频器代码:将10MHz脉冲变成100Hz程序:library ieee;use ieee.std_logic_1164.all;entity fenpin is port(clr,clk: in bit;q: buffer bit);end fenpi

4、n;architecture a of fenpin is   signal counter:integer range 0 to 49999;begin    process(clr,clk)      begin  if (clk='1' and clk'event) then         if clr='1' then  

5、60;         counter<=0;  elsif counter=49999 then            counter<=0;            q<= not q;    else 

6、60;          counter<=counter+1;         end if;       end if;     end process;end a;分频器的仿真图:2.十进制计数器:原理为加法计数器,从0加到9,计到10个数时由cout进位程序:library ieee; use ieee.std_l

7、ogic_1164.all;use ieee.std_logic_unsigned.all;entity c10 is    port(clr,start,clk: in bit;      cout: out bit;      daout: out std_logic_vector(3 downto 0);end c10;,architecture a of c10 is    signal temp:std_l

8、ogic_vector(3 downto 0);begindaout<=temp;    process(clk,clr)    begin        if clr='1' then                temp<="0000" 

9、0;             cout<='0'         elsif (clk'event and clk='1') then               if start='1' then 

10、0;          if temp>="1001" then                 temp<="0000"              

11、;   cout<='1'                  else                     temp<=temp+1;    

12、60;                 cout<='0'                  end if;             &#

13、160;  end if;         end if;          end process;end a;十进制计数器仿真图:3.六进制计数器:原理为加法计数器,从0 加到5计到第六个数时由cout进位。程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity c6 is    port(cl

14、r,start,clk: in bit;         daout: out std_logic_vector(3 downto 0);         cout: out std_logic);end c6;architecture a of c6 is    signal temp:std_logic_vector(3 downto 0);begindaout<=temp;  

15、;  process(clk,clr)    begin       if clr='1' then              temp<="0000"             cout<='0'

16、        elsif (clk'event and clk='1') then       if start='1' then        if temp>="0101" then             

17、      temp<="0000"                  cout<='1'                 else   &#

18、160;                temp<=temp+1;                     cout<='0'         

19、;        end if;               end if;        end if; end process; end a;6进制计数器仿真图:4、二十四进制计数器采用一个二进制的计数器和一个四进制的计数器相结合到一起,低位从0到9,到9向高位进一,当低位计到四,高位计到2,进行进位输出,即每二十四个数进行一次进位输

20、出library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity c24 isport(clr,start,clk:in std_logic;hour1,hour0:out std_logic_vector(3 downto 0);end c24;architecture a of c24 isbegin process(clr,clk)variable cnt1,cnt0:std_logic_vector(3 downto 0);beginif clr='1' then cnt0:

21、="0000" cnt1:="0000"elsif clk'event and clk='1' thenif start='1' thenif cnt1="0010" and cnt0="0011"then cnt1:="0000"cnt0:="0000"elsif cnt0<"1001" then cnt0:=cnt0+1;else cnt0:="0000"cnt1:=cnt1+1;end

22、 if;end if;end if;hour1<=cnt1;hour0<=cnt0;end process;end a;24进制计数器仿真图:5.数据选择和数码管选择模块代码:其功能是选择计数端口来的数据,当相应的数据到来时数据选择器数据后输数给数码管,并由数码管显示。八个数码管分别显示小时,分钟,秒,百分秒library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity seltime isport(clk: in bit;dain0,dain1,dain2,dain3,dain4,da

23、in5,dain6,dain7: in std_logic_vector(3 downto 0);sel: out std_logic_vector(2 downto 0);daout: out std_logic_vector(3 downto 0);end seltime;architecture a of seltime issignal temp:integer range 0 to 7;beginprocess(clk)beginif (clk='1'and clk'event) thenif temp=7 then temp<=0;else temp&

24、lt;=temp + 1;end if;case temp iswhen 0=>sel<="000"daout<=dain0;when 1=>sel<="001"daout<=dain1;when 2=>sel<="010"daout<=dain2;when 3=>sel<="011"daout<=dain3;when 4=>sel<="100"daout<=dain4;when 5=>sel<

25、="101"daout<=dain5;when 6=>sel<="110"daout<=dain6;when 7=>sel<="111"daout<=dain7;end case;end if;end process;end a;仿真图:5.数码管驱动模块代码:数码管驱动电路,驱动数码管发光。library ieee;use ieee.std_logic_1164.all;entity deled isport(num:in std_logic_vector(3 downto 0);led:out std_logic_vector(6 downto 0);end deled ;architecture a of deled isbeginprocess(num)begincase num iswhen"0000"=>led<="0111111"-3FHwhen"0001"=>led<="0000110"-06Hwhen"0010&quo

温馨提示

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

评论

0/150

提交评论