江苏大学
数字逻辑课程设计
___________
多功能数字钟
专业:软件1001
学号:3100608024
姓名:张同学
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<='1'when (count=\'0'; 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=\count<=\else
count<=count+1; end if; else
count<=count; end if; else
count<=count; end if; else
count<=data; 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)<=m1; q(11 downto 8)<=m0; q(7 downto 4)<=s1;