《FPGA秒表实验报告(共10页).doc》由会员分享,可在线阅读,更多相关《FPGA秒表实验报告(共10页).doc(10页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上课程设计报告专业班级 课 程 题 目 秒表的设计 学 号 姓 名 同 组 人 成 绩 2013年5月专心-专注-专业一、设计目的1.进一步熟悉七段码译码器的硬件接口。2.掌握用扫描方法驱动多个数码管硬件接口。3.掌握秒表VHDL的编程方法。二、系统总体设计(1).设计要求:1.秒表共有6个输出显示,分别为百分之一秒、十分之一秒、秒、十秒、分、十分,所以共有6个计数器与之相对应,6个计数器的输出全都为BCD码输出,这样便于和显示译码器的连接。当计时达60分钟后,蜂鸣器鸣响10声。2.整个秒表还需有一个启动信号和一个归零信号,以便秒表能随意停止及启动。3.秒表的逻辑结构较
2、简单,它主要由显示译码器、分频器、十进制计数器、六进制计数器和报警器组成。在整个秒表中最关键的是如何获得一个精确的100HZ计时脉冲。(2).实验原理:秒表由于其计时精确,分辨率高(0.01秒),在各种竞技场所得到了广泛的应用。秒表的工作原理与数字时基本相同,唯一不同的是秒表的计时时钟信号,由于其分辨率为0.01秒,所以整个秒表的工作时钟是在100Hz的时钟信号下完成。当秒表的计时小于1个小时时,显示的格式是mm-ss-xx(mm表示分钟:059;ss表示秒:059;xx表示百分之一秒:099),当秒表的计时大于或等于一个小时时,显示的和多功能时钟是一样的,就是hh-mm-ss(hh表示小时:
3、099),由于秒表的功能和钟表有所不同,所以秒表的hh表示的范围不是023,而是099,这也是和多功能时钟不一样的地方。在设计秒表的时候,时钟的选择为100Hz。变量的选择:因为xx(0.01秒)和hh(小时)表示的范围都是099,所以用两个4位二进制码(BCD码)表示;而ss(秒钟)和mm(分钟)表示的范围是059,所以用一个3位的二进制码和一个4位的二进制码(BCD)码表示。显示的时候要注意的问题就是小时的判断,如果小时是00,则显示格式为mm-ss-xx,如果小时不为00,则显示hh-mm-ss。三、详细设计1.计时模块:计时模块执行计时功能,计时方法和计算机一样是对标准时钟脉冲计数。他
4、是由四个十进制计数器和俩个六进制计数器构成,其中毫秒位、十毫秒位、秒位和分位采用十进制计数器,十秒位和十分位采用六进制计数器。源程序:(1)十进制计数器(count_10)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity COUNT10 isport (CLK,START,CLR : in std_logic; COUT : out std_logic; DAOUT : out std_logic_vector(3 downto 0);end COUNT10;architecture
5、one of COUNT10 issignal h0 : std_logic_vector(3 downto 0);signal h1 : std_logic;beginprocess(CLK,CLR)begin if CLR=1 then h0=0000; elsif CLKevent and CLK=1 then if START=1 then if h0=1001 then h0=0000; h1=1; else h0=h0+1; h1=0; end if; end if; end if;end process;DAOUT=h0;COUT=h1;end one;(2)六进制计数器(cou
6、nt_6)library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity COUNT6 isport (CLK,START,CLR : in std_logic; COUT : out std_logic; DAOUT: out std_logic_vector(3 downto 0);end COUNT6;architecture two of COUNT6 issignal h0 : std_logic_vector(3 downto 0);signal h1 : std_logic;begin
7、process(CLK,CLR)begin if CLR=1 then h0=0000; elsif CLKevent and CLK=1 then if START=1 then if h0=0101 then h0=0000; h1=1; else h0=h0+1; h1=0; end if; end if; end if;end process;DAOUT=h0;COUTledledledledledledledledledledled=;end case;end process;end a;3.分频library ieee;use ieee.std_logic_1164.all;ent
8、ity fenpin is port(clr,clk: in std_logic;q: buffer std_logic);end fenpin;architecture b of fenpin is signal counter:integer range 0 to 49999;begin process(clr,clk) begin if (clk=1 and clkevent) then if clr=1 then counter=0; elsif counter=49999 then counter=0; q= not q; else counter=counter+1; end if
9、; end if; end process;end b;4.位选library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity seltime isport ( clk:in std_logic; clr:in std_logic; dain0:in std_logic_vector(3 downto 0); dain1:in std_logic_vector(3 downto 0); dain2:in std_logic_vector(3 downto 0); dain3:in std_logic
10、_vector(3 downto 0); dain4:in std_logic_vector(3 downto 0); dain5:in std_logic_vector(3 downto 0); daout:buffer std_logic_vector(3 downto 0); sel:buffer std_logic_vector(2 downto 0);end seltime;architecture three of seltime issignal m:std_logic_vector(2 downto 0);signal n:std_logic_vector(3 downto 0
11、);beginn=0000 when clr=1 else dain0 when m=000 else dain1 when m=001else dain2 when m=010else dain3 when m=011else dain4 when m=100 else dain5;process(clr,clk,dain0,dain1,dain2,dain3,dain4,dain5)beginif clk event and clk=1thenif m=101 then m=000;else m =m+1;end if;end if;sel=m;end process;daout=n;en
12、d three;5.警告library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity ALARM isport (CLK: in std_logic; dain: in std_logic; q: out std_logic);end ALARM;architecture four of ALARM issignal count: std_logic_vector(1 downto 0);beginprocess(clk)beginq=count(1);if(clkevent and clk=1)
13、 then if(dain=1)then if(count=10)then count=00; else count=count+1; end if; end if; end if; end process; q=count(1);end four;原理图:四、仿真分析1.仿真结果:2.管脚分配:五.设计中遇到的问题及解决方法问题:1.对秒表设计的原理理解不到位,试验不能正常进行。2.因为程序输入不正确,导致程序编译不成功。3.管脚分配不合理,导致结果不能显示或者不能正常显示。解决方法:1. 进一步理解实验的原理,各部分的组成以及功能。2. 运行程序之前仔细检查程序,并适当注释。3. 按照规定
14、分配管脚,注意区别不能定义的管脚。六 心得体会:因为对EDA技术及Quartus软件的相关知识知道的不够深入,在设计过程中我们遇到了很多困难,但通过从网上找一些相关资料,最终完成了设计任务。 开始做设计时总是会出现各种错误,经过不停的编译及改错最终得到了正确的程序。其实这些错误的主要原因是自己的粗心造成的,如果细心一些这些错误时可以避免的。在编程时,要使用层次化结构的思想,这样程序检查起来也比较方便,调试时也给了自己很大的方便,只要一个模块一个模块的进行调就可以了,充分体现了结构化编程的优势。在设计中要求我们要有耐心和毅力,还要细心,稍有不慎,一个小小的错误就会导致结果的不正确,而对错误的检查要求我们要有足够的耐心,通过这次设计和设计中遇到的问题,也积累了一定的经验,对以后从事集成电路设计工作会有一定的帮助。 在应用VHDL的过程中让我真正领会到了其并行运行与其他软件顺序执行的差别及其在电路设计上的优越性。用VHDL硬件描述语言的形式来进行数字系统的设计方便灵活,利用EDA软件进行编译优化仿真极大地减少了设计时间和可能发生的错误,降低了开发成本,这种设计方法在数字系统设计中发挥越来越重要的作用。总之这次的设计受益匪浅。