数字逻辑电路课程设计报告--多功能数字钟
江苏大学
数字逻辑课程设计 ___________多功能数字钟
学号:
2012年1月11日
一、设计目的
1、学会应用数字系统方法进行电路设计;
2、进一步提高Maxplus Ⅱ软件开发应用能力;
3、培养综合实验的能力;
二、设计要求
1、能进行正常的记时、记分、记秒
2、实现校时、校分以及秒清0的功能
3、实现整点报时的功能
4、实现时间的正常显示
5、闹时功能的实现
三、具体设计思路
1、利用按键实现“校时”、 “校分”和“秒清0”功能。
(1)SA :校时键。按下SA 键时,时计数器迅速递增,按24小时循环,并且计满23时回到00。
(2)SB :校分键。按下SB 键时,分计数器迅速递增,按60小时循环,并且计满59时回到00,但不向时进位。
(3)SC :秒清零。按下SC 时,秒计数器清零。
要求按键均不产生数字跳变,因此须对“SA ”、“SB ”进行消抖处理。 实现:
①:十进制计数器的设计:
VHDL 描述:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ls160 is port(
data:in std_logic_vector(3 downto 0);
clk,ld,p,t,clr:in std_logic;
count:buffer std_logic_vector(3 downto 0);
tc:out std_logic);
end ls160;
architecture behavior of ls160 is
begin
tc
cale:
process(clk,clr,p,t,ld)
begin
if(rising_edge(clk))then
if(clr='1')then
if(ld='1')then
if(p='1')then
if(t='1')then
if(count="1001")then
count
else
count
end if;
else
count
end if;
else
count
end if;
else
count
end if;
else
count
end if;
end if;
end process cale;
end behavior;
②24进制计数器和60进制计数器的设计(以十进制计数器为基础):
24进制计数器:
60进制计数器:
仿真图:
2、能进行整点报时。
(1)在59分50、52、54、56、58秒按500Hz 频率报时;
(2)在59分60秒用1KHz 的频率作最后一声正点报时。
VHDL描述:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity baoshi is
port(m1,m0,s1,s0 : in std_logic_vector(3 downto 0);
sig500,sig1k : out std_logic);
end hourring;
architecture a of baoshi is
signal q : std_logic_vector(15 downto 0);
signal s500,s1k : std_logic;
begin
q(15 downto 12)
q(11 downto 8)
q(7 downto 4)
q(3 downto 0)
hring : block
begin
s500
'1' when q="[**************]0" else
'1' when q="[**************]0" else
'1' when q="[**************]0" else
'1' when q="[**************]0" else
'0';
s1k
'0';
end block hring;
sig500
sig1k
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="1111111111"then
clk
else clk
end if;
end if;
end process;
hz512
hz256
hz64
hz4
hz1
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
end if;
end process rt1_dtsm;
process(q)
begin
case q is
when"000"=>sel
when"001"=>sel
when"010"=>sel
when"011"=>sel
when"100"=>sel
when"101"=>sel
when others=>sel
end case;
end process;
process
begin
if sel ="000001"then
number
elsif sel="000010"then
number
elsif sel="000100"then
number
elsif sel="001000"then
number
elsif sel="010000"then
number
elsif sel="100000"then
number
else
number
end if;
end process;
process(number)
begin
case number is
when"0000"=>seg
when"0001"=>seg
when"0010"=>seg
when"0011"=>seg
when"0100"=>seg
when"0101"=>seg
when"0110"=>seg
when"0111"=>seg
when"1000"=>seg
when"1001"=>seg
when others=>seg
end case;
end process;
selout
segout
end rt1_dtsm;
附:顶层图
四、遇到的问题及解决方法
1、为了连接方便,对图经行必要的旋转时,导致了输入输出移位,以致编译错误,耗费了大量时间,可见细节很重要。
2、做七段显示器时,由于扫描频率过低,显示闪烁,当频率高于256时,可以正常显示。
3、报时时需要两个不同的频率。通过电路中两个与门和一个或门将两个不同信号选择的送到扬声器。
五、设计结果
下载到实验板上后,可以在七段数码管上正确显示时间,且具有整点报时、手动校时的功能,但是没有实现闹铃功能。
六、实验总结
通过这次多功能数字钟的设计实验,让我基本上掌握了VHDL 语言的编写和图形连接,使我熟悉了对MaxPlus II软件的使用并加深了对VHDL 语言编程和图形编辑的认识和了解。也同时更加熟练的掌握了运用波形图进行仿真以及下载测试。 也让我了解了关于数字钟的原理与设计理念,要设计一个电路先进行软件模拟仿真再进行实际的电路制作。但是最后的成品却不一定与仿真时完全一样,因为,再实际接线中有着各种各样的条件制约着。而且,在仿真中无法成功的电路接法,在实际中因为芯片本身的特性而能够成功。所以,在设计时应考虑两者的差异,从中找出最适合的设计方法。通过这次学习,让我对各种电路都有了大概的了解,所以说,坐而言不如立而行,对于这些电路还是应该自己动手实际,在今后的学习中,还要多去实践书本的内容,学到更多的知识。