q(3 downto 0)<=s0; hring : block begin
s500<='1' when q=\ '1' when q=\ '1' when q=\ '1' when q=\ '1' when q=\ '0';
s1k<='1' when q=\ '0'; end block hring; sig500<=s500; sig1k<=s1k; end a;
3.程序中由于需要输入多个不同的时钟信号,故需要设计一个分频器,使输入时钟信号简化。
VHDL描述: library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity frequencydivider is port(cp:in std_logic;
hz512,hz256,hz64,hz4,hz1:out std_logic); end frequencydivider;
architecture one of frequencydivider is SIGNAL clk: std_logic_vector(9 downto 0); begin
process(cp) begin
if cp'event and cp='1'then if clk=\ clk<=\ else clk<=clk+1; end if; end if; end process; hz512<=clk(0);
hz256<=clk(1); hz64<=clk(3); hz4<=clk(7); hz1<=clk(9); end one;
分频仿真图:
4、能进行正常的时、分、秒计时,用动态扫描的方式显示,需用6个数码管。
(1) 用M6M5进行24进制小时的显示。 (2) 用M4M3进行60进制分的显示。 (3) 用M2M1进行60进制秒的显示。
动态扫描用VHDL描述:
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all;
entity dtsm is
port(clk:in std_logic;
s :in std_logic_vector(7 downto 0); f :in std_logic_vector(7 downto 0); m :in std_logic_vector(7 downto 0);
selout:out std_logic_vector(5 downto 0); segout:out std_logic_vector(6 downto 0) ); end dtsm ;
architecture rt1_dtsm of dtsm is
signal number:std_logic_vector(3 downto 0); signal sel :std_logic_vector(5 downto 0); signal seg :std_logic_vector(6 downto 0); signal q :std_logic_vector(2 downto 0); begin
rt1_dtsm:process(clk) begin
if(clk'event and clk='1')then q<=q+1; end if;
end process rt1_dtsm;
process(q) begin
case q is
when\when\
when\when\when\when\when others=>sel<=\end case; end process;
process begin
if sel =\
number<=m(3 downto 0); elsif sel=\
number<=m(7 downto 4); elsif sel=\
number<=f(3 downto 0); elsif sel=\
number<=f(7 downto 4); elsif sel=\
number<=s(3 downto 0); elsif sel=\
number<=s(7 downto 4); else
number<=\end if;
end process;
process(number) begin
case number is
when\ when\ when\ when\ when\ when\ when\ when\ when\ when\ when others=>seg<=\end case; end process;
selout<=sel; segout<=seg; end rt1_dtsm;
附:顶层图
四、遇到的问题及解决方法
1、为了连接方便,对图经行必要的旋转时,导致了输入输出移位,以致编译错误,耗费了大量时间,可见细节很重要。
2、做七段显示器时,由于扫描频率过低,显示闪烁,当频率高于256时,可以正常显示。 3、报时时需要两个不同的频率。通过电路中两个与门和一个或门将两个不同信号选择的送到扬声器。
五、设计结果
下载到实验板上后,可以在七段数码管上正确显示时间,且具有整点报时、手动校时的功能,但是没有实现闹铃功能。
六、实验总结
通过这次多功能数字钟的设计实验,让我基本上掌握了VHDL语言的编写和图形连接,使我熟悉了对MaxPlus II软件的使用并加深了对VHDL语言编程和图形编辑的认识和了解。也同时更加熟练的掌握了运用波形图进行仿真以及下载测试。 也让我了解了关于数字钟的原理与设计理念,要设计一个电路先进行软件模拟仿真再进行实际的电路制作。但是最后的成品却不一定与仿真时完全一样,因为,再实际接线中有着各种各样的条件制约着。而且,在仿真中无法成功的电路接法,在实际中因为芯片本身的特性而能够成功。所以,在设计时应考虑两者的差异,从中找出最适合的设计方法。通过这次学习,让我对各种电路都有了大概的了解,所以说,坐而言不如立而行,对于这些电路还是应该自己动手实际,在今后的学习中,还要多去实践书本的内容,学到更多的知识。