当前位置:文档之家› EDA课程设计数字秒表

EDA课程设计数字秒表

课程设计题院目系数字秒表设计信息工程学院班级姓名指导教师目录第1章:系统设计要求 (3)第2章:实验目的 (3)第3章:实验原理 (3)第4章:系统设计方案 (3)第5章:主要VHDL源程序 (4)1)十进制计数器的VHDL 源程序. (4)2) 六进制计数器的VHDL 源程序 (5)3)蜂鸣器的VHDL源程序. (5)4)译码器的VHDL源程序. (6)5)控制选择器的VHDL源程序 (7)6)元原件例化的VHDL源程序 (8)第六章:系统仿真. (10)第七章:系统扩展思路. (11)第八章:设计心得总结. (11)数字秒表的设计1、系统设计要求1.秒表共有6个输出显示,分别为百分之一秒、十分之一秒、秒、十秒、分、十分,所以共有6个计数器与之相对应,6个计数器的输出全都为BCD码输出,这样便于和显示译码器的连接。

当计时达60分钟后,蜂鸣器鸣响10声。

2.整个秒表还需有一个启动信号和一个归零信号,以便秒表能随意停止及启动。

3.秒表的逻辑结构较简单,它主要由显示译码器、分频器、十进制计数器、六进制计数器和报警器组成。

在整个秒表中最关键的是如何获得一个精确的100HZ计时脉冲。

2、实验目的通过本次课设,加深对EDA技术设计的理解,学会用QuartusⅡ工具软件设计基本电路,熟练掌握VHDL语言,为以后工作使用打下坚实的基础。

3、实验原理秒表由于其计时精确,分辨率高(0.01秒),在各种竞技场所得到了广泛的应用。

秒表的工作原理与数字时基本相同,唯一不同的是秒表的计时时钟信号,由于其分辨率为0.01秒,所以整个秒表的工作时钟是在100Hz的时钟信号下完成。

当秒表的计时小于1个小时时,显示的格式是mm-ss-xx(mm 表示分钟:0~59;ss表示秒:0~59;xx表示百分之一秒:0~99),当秒表的计时大于或等于一个小时时,显示的和多功能时钟是一样的,就是hh-mm-ss(hh表示小时:0~99),由于秒表的功能和钟表有所不同,所以秒表的hh 表示的范围不是0~23,而是0~99,这也是和多功能时钟不一样的地方。

在设计秒表的时候,时钟的选择为100Hz。

变量的选择:因为xx(0.01 秒)和hh(小时)表示的范围都是0~99,所以用两个4位二进制码(BCD码)表示;而ss(秒钟)和mm(分钟)表示的范围是0~59,所以用一个3位的二进制码和一个4位的二进制码(BCD)码表示。

显示的时候要注意的问题就是小时的判断,如果小时是00,则显示格式为mm-ss-xx,如果小时不为00,则显示hh-mm-ss。

4、系统设计方案秒表的逻辑结构较简单,它主要由显示译码器、分频器、十进制计数器、六进制计数器和报警器组成。

四个10进制计数器:用来分别对百分之一秒、十分之一秒、秒和分进行计数;两个6进制计数器:用来分别对十秒和十分进行计数;分频器:用来产生100HZ计时脉冲;显示译码器:完成对显示的控制。

根据电路持点,用层次设计概念将此设计任务分成若干模块,规定每一模块的功能和各模块之间的接口。

按适配划分后的管脚定位,同相关功能块硬件电路接口连线。

用VHDL语言描述所有底层模块。

清零信号为异步清零。

当最高位记到6时停止计数显示译码器全部显示零,并发出十声警报声。

按下复位按钮后继续计数。

数字秒表拟由单片的CPLD/FPGA 来实现,经分析设计要求,拟定整个系统由10个模块组成,原理图如下:5、主要VHDL源程序1.十进制计数器的VHDL 源程序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(3downto 0));end count10;architecture one of count10 issignal q0: std_logic_vector(3downto0);signal q1: std_logic;beginprocess(clk,clr)beginif clr='1'then q0<="0000";elsif(clk'event and clk='1')thenif start='1' thenif q0="1001"then q0<="0000";q1<='1';else q0<=q0+1;q1<='0';end if;end if;end if;end process;daout<=q0;cout<=q1;end one;2.六进制计数器的VHDL 源程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity count6isport(clk,start,clr: in std_logic;cout:out std_logic;daout:out std_logic_vector(3downto 0)); end count6;architecture two of count10 issignal q0: std_logic_vector(3downto0);signal q1: std_logic;beginprocess(clk,clr)beginif clr='1'then q0<="0000";elsif(clk'event and clk='1')thenif start='1' thenif q0="0101"then q0<="0000";q1<='1';else q0<=q0+1;q1<='0';end if;end if;end if;end process;daout<=q0;cout<=q1;end two;3.蜂鸣器的VHDL源程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity alarm isport(clk,I:in std_logic;q:out std_logic);end alarm;architecture ar of alarm issignal n:integer range 0to20;signal q0:std_logic;beginprocess(clk)beginif clk'event and clk='1'thenif i='0'then q0<='0';n<=0;elsif n<=19and i='1'thenq0<=not q0;n<=n+1;else q0<='0';end if;end if;end process;q<=q0;end ar;4.译码器的VHDL源程序library ieee;use ieee.std_logic_1164.all;entity deled isport(num:in std_logic_vector(3 downto 0);led:out std_logic_vector(6downto 0)); end deled;architecture a of deled isbeginprocess(num)begincase num iswhen"0000"=>led<="0111111";when"0001"=>led<="0000110";when"0010"=>led<="1011011";when"0011"=>led<="1001111";when"0100"=>led<="1100110";when"0101"=>led<="1101101";when"0110"=>led<="1111101";when"0111"=>led<="0100111";when"1000"=>led<="1111111";when"1001"=>led<="1101111";when others=>led<="0000000";end case;end process;end a;5.控制选择器的VHDL源程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity seltime isport(clr,clk:in bit;dain0,dain1,dain2,dain3,dain4,dain5: in std_logic_vector(3 downto 0);sel: out std_logic_vector(2downto 0);daout:out std_logic_vector(3downto 0));end seltime;architecture a of seltime issignal temp:integer range 0 to 5;beginprocess(clk)beginif(clr='1')thendaout<="0000";sel<="000";temp<=0;elsif(clk='1'and clk'event) thenif temp=5then temp<=0;else temp<=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<="101";daout<=dain5;end case;end if;end process;end a;6.分频器的VHDL源程序library ieee;use ieee.std_logic_1164.all;entity div isport(clr,clk:in std_logic;q: buffer std_logic);end div;architecture a of div issignal count:integer range0to99999;beginprocess(clr,clk)beginif(clk'event and clk='1')thenif clr='1'thencount<=0;elsif count=99999 thencount<=0;q<=not q;elsecount<=count+1;end if;end if;end process;end a;7.元原件例化的VHDL源程序library ieee;use ieee.std_logic_1164.all;entity mb_top isport(stop,start,clk:in std_logic;a,b,c,d,e,f,g,speaker:out std_logic;sel:out std_logic_vector(2downto 0)); end mb_top;architecture a of mb_top iscomponent divport(clr,clk:in std_logic;q: buffer std_logic);end component;component count10port(clr,start,clk:in std_logic;cout:out std_logic;daout:buffer std_logic_vector(3downto 0));end component;component count6port(clr,start,clk:in std_logic;cout:out std_logic;daout:buffer std_logic_vector(3downto 0));end component;component seltimeport(clr,clk:in std_logic;dain1:in std_logic_vector(3downto 0);dain2:in std_logic_vector(3downto 0);dain3:in std_logic_vector(3downto 0);dain4:in std_logic_vector(3downto 0);dain5:in std_logic_vector(3downto 0);dain6:in std_logic_vector(3downto 0);sel:out std_logic_vector(2downto 0);daout:out std_logic_vector(3downto 0));end component;component deledport(num:in std_logic_vector(3downto 0);led:out std_logic_vector(6downto 0));end component;component alarmport(clk,i:in std_logic;q:out std_logic);end component;signal div_q,b_cout,s_cout,m_cout,sm_cout,f_cout,sf_cout:std_logic;signalb_daout,s_daout,m_daout,sm_daout,f_daout,sf_daout,seltime_daout:std_logic_v ector(3downto 0);signal ledout:std_logic_vector(6downto 0);begina<=ledout(0);b<=ledout(1);c<=ledout(2);d<=ledout(3);e<=ledout(4);f<=ledout(5);g<=ledout(6);u1:div port map(stop,clk,div_q);u2:count10port map(stop,start,div_q,b_cout,b_daout);u3:count10port map(stop,start,b_cout,s_cout,s_daout);u4:count10port map(stop,start,s_cout,m_cout,m_daout);u5:count6 port map(stop,start,m_cout,sm_cout,sm_daout);u6:count10port map(stop,start,sm_cout,f_cout,f_daout);u7:count6 port map(stop,start,f_cout,sf_cout,sf_daout);u8:seltime port map(stop,div_q,b_daout,s_daout,m_daout,sm_daout,f_daout,sf_daout,sel,seltime _daout);u9:deled port map(seltime_daout,ledout);u10:alarm port map(div_q,sf_cout,speaker);end a;6、系统仿真1.十进制2.六进制3.蜂鸣器4.译码器5.控制选择器7、系统扩展思路根据实验的内容可以适当的添加一些有实际作用和可行性的功能,如可以记录并显示多个数据。

相关主题