VHDL数字秒表设计.docx

上传人:b****6 文档编号:5741521 上传时间:2022-12-31 格式:DOCX 页数:11 大小:392.36KB
下载 相关 举报
VHDL数字秒表设计.docx_第1页
第1页 / 共11页
VHDL数字秒表设计.docx_第2页
第2页 / 共11页
VHDL数字秒表设计.docx_第3页
第3页 / 共11页
VHDL数字秒表设计.docx_第4页
第4页 / 共11页
VHDL数字秒表设计.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

VHDL数字秒表设计.docx

《VHDL数字秒表设计.docx》由会员分享,可在线阅读,更多相关《VHDL数字秒表设计.docx(11页珍藏版)》请在冰豆网上搜索。

VHDL数字秒表设计.docx

VHDL数字秒表设计

 

 

VHDL数字秒表设计

 

专业:

自动化

班级学号:

5090629

姓名:

刘丹

 

2011年6月14日

VHDL语言课程设计-秒表设计

一、设计实验目的:

在MAX+plusII软件平台上,熟练运用VHDL语言,完成数字时钟设计的软件编程、编译、综合、仿真,使用EDA实验箱,实现数字秒表的硬件功能。

二、设计实验说明及要求:

1、数字秒表主要由:

分频器、扫描显示译码器、一百进制计数器、六十进制计数器(或十进制计数器与6进制计数器)、十二进制计数器(或二十四进制计数器)电路组成。

在整个秒表中最关键的是如何获得一个精确的100HZ计时脉冲,除此之外,数字秒表需有清零控制端,以及启动控制端、保持保持,以便数字时钟能随意停止及启动。

2、数字秒表显示由时(12或24进制任选)、分(60进制)、秒(60进制)、百分之一秒(一百进制)组成,利用扫描显示译码电路在八个数码管显示。

3、能够完成清零、启动、保持(可以使用键盘或拨码开关置数)功能。

4、时、分、秒、百分之一秒显示准确。

三、我的设计思路:

   1、四个十进制计数器:

用来分别对百分之一秒、十分之秒、秒和分进行计数;

   2、两个6进制计数器:

用来分别对十秒和十分进行计数;

3、一个24进制计数器,用来对小时进行计数;

   3、分频率器:

用来产生100Hz的计数脉冲;

   4、显示译码器:

完成对显示译码的控制。

四、设计过程:

1.分频器:

由10MHz变为100Hz,10MHz的周期是10的(-7)次方,而100Hz的周期是10的(-2)次方,而且方波是高低相间,只有高电平有效,所以100Hz的周期需要取一半,即秒,这样算出的分频倍数就是50000

分频器代码:

将10MHz脉冲变成100Hz

程序:

libraryieee;

use

entityfenpinis

 port(clr,clk:

inbit;q:

bufferbit);

endfenpin;

architectureaoffenpinis

  signalcounter:

integerrange0to49999;

begin

   process(clr,clk)

     begin

  if(clk='1'andclk'event)then      

  ifclr='1'then

           counter<=0;

  elsifcounter=49999then

           counter<=0;

           q<=notq;

    else

           counter<=counter+1;

        endif;

      endif;

    endprocess;

enda;

分频器的仿真图:

2.十进制计数器:

原理为加法计数器,从0加到9,计到10个数时由cout进位

程序:

libraryieee;

use

use

entityc10is

   port(clr,start,clk:

inbit;

      cout:

outbit;

      daout:

outstd_logic_vector(3downto0));

endc10;,

architectureaofc10is

   signaltemp:

std_logic_vector(3downto0);

begin

daout<=temp;

    process(clk,clr)

    begin

       ifclr='1'then

              temp<="0000";

              cout<='0';

       elsif(clk'eventandclk='1')then

              ifstart='1'then

           iftemp>="1001"then

                temp<="0000";

                 cout<='1';

                else

                   temp<=temp+1;  

                   cout<='0';

                endif;

              endif;

       endif;

    

    endprocess;

enda;

十进制计数器仿真图:

 

3.六进制计数器:

原理为加法计数器,从0加到5计到第六个数时由cout进位。

程序:

libraryieee;

use

usec6is

   port(clr,start,clk:

inbit;

        daout:

outstd_logic_vector(3downto0);

        cout:

outstd_logic);

endc6;

architectureaofc6is

   signaltemp:

std_logic_vector(3downto0);

begin

daout<=temp;

   process(clk,clr)

   begin

      ifclr='1'then

            temp<="0000";

            cout<='0';

      elsif(clk'eventandclk='1')then

       ifstart='1'then

       iftemp>="0101"then

                  temp<="0000";

                  cout<='1';

               else

                  temp<=temp+1;  

                  cout<='0';

               endif;

             endif;

      endif;

endprocess;

enda;

6进制计数器仿真图:

4、二十四进制计数器

采用一个二进制的计数器和一个四进制的计数器相结合到一起,低位从0到9,到9向高位进一,当低位计到四,高位计到2,进行进位输出,即每二十四个数进行一次进位输出

libraryieee;

usec24is

port(clr,start,clk:

instd_logic;

hour1,hour0:

outstd_logic_vector(3downto0));

endc24;

architectureaofc24is

begin

process(clr,clk)

variablecnt1,cnt0:

std_logic_vector(3downto0);

begin

ifclr='1'thencnt0:

="0000";cnt1:

="0000";

elsifclk'eventandclk='1'then

ifstart='1'then

ifcnt1="0010"andcnt0="0011"

thencnt1:

="0000";

cnt0:

="0000";

elsifcnt0<"1001"thencnt0:

=cnt0+1;

elsecnt0:

="0000";

cnt1:

=cnt1+1;

endif;

endif;

endif;

hour1<=cnt1;

hour0<=cnt0;

endprocess;

enda;

24进制计数器仿真图:

5.数据选择和数码管选择模块代码:

其功能是选择计数端口来的数据,当相应的数据到来时数据选择器数据后输数给数码管,并由数码管显示。

八个数码管分别显示小时,分钟,秒,百分秒

libraryieee;

useseltimeis

port(clk:

inbit;

dain0,dain1,dain2,dain3,dain4,dain5,dain6,dain7:

instd_logic_vector(3downto0);

sel:

outstd_logic_vector(2downto0);

daout:

outstd_logic_vector(3downto0));

endseltime;

architectureaofseltimeis

signaltemp:

integerrange0to7;

begin

process(clk)

begin

if(clk='1'andclk'event)then

iftemp=7thentemp<=0;

elsetemp<=temp+1;

endif;

casetempis

when0=>sel<="000";daout<=dain0;

when1=>sel<="001";daout<=dain1;

when2=>sel<="010";daout<=dain2;

when3=>sel<="011";daout<=dain3;

when4=>sel<="100";daout<=dain4;

when5=>sel<="101";daout<=dain5;

when6=>sel<="110";daout<=dain6;

when7=>sel<="111";daout<=dain7;

endcase;

endif;

endprocess;

enda;

仿真图:

5.数码管驱动模块代码:

数码管驱动电路,驱动数码管发光。

libraryieee;

usedeledis

port(num:

instd_logic_vector(3downto0);

led:

outstd_logic_vector(6downto0));

enddeled;

architectureaofdeledis

begin

process(num)

begin

casenumis

when"0000"=>led<="0111111";-----------3FH

when"0001"=>led<="0000110";-----------06H

when"0010"=>led<="1011011";-----------5BH

when"0011"=>led<="1001111";-----------4FH

when"0100"=>led<="1100110";-----------66H

when"0101"=>led<="1101101";-----------6DH

when"0110"=>led<="1111101";-----------7DH

when"0111"=>led<="0100111";-----------27H

when"1000"=>led<="1111111";-----------7FH

when"1001"=>led<="1101111";-----------6FH

whenothers=>led<="0000000";-----------00H

endcase;

endprocess;

enda;

 

五、秒表原理图

 

六:

实验总结

通过本次的课程设计,我初步了解了vhdl语言的编程思想,以及利用EDA软件进行电子电路设计的方法,通过对一个课题的分析,将实验的内容进行分块解读,具体到每一个模块的具体作用,然后将各个功能的模块通过连线进行总体的电路实现,也可以通过Vhdl语言对各个模块进行组合,然后需要在程序编译成功的基础上,安装硬件,将程序下载到具体的芯片上进行硬件的实现。

通过整个实验的完成,我从老师和同学那里学到了更多关于vhdl编程,仿真以及硬件实现的知识,自己以前模糊不清的地方也通过此次的课程设计了解清楚了,并且通过这次课程设计,我也锻炼了独立思考,独立操作的能力,虽然对于vhdl语言的应用我还很生疏,但是此次的课程设计却让我学到了很多,也对这门语言有了更深的理解,对eda软件的使用有了更多的体会。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 工作计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1