万年历时钟表

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

本次课程设计要求显示万年历时钟表。要求实现正常的时、分、秒计数。二十四小时的时间计时。

本次课程设计采用黑金AX301开发平台。相关硬件原理图和PCB图见文件夹。

一.各个设计模块描述

(一)计时模块

1.秒计数是由一个六十进制的计数器构成,生成元器件如下

Clk:驱动秒计时器的时钟信号

Clr:校准时间时清零的输入端

En:使能端

Sec0[3..0] sec1[3..0]:秒的高位显示,低位显示

Co:进位输出端,作为分的clk输入

代码如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity second is

port (clk,clr,en:in std_logic;

sec0,sec1:out std_logic_vector(3 downto 0);

co:out std_logic);

end second;

architecture sec of second is

SIGNAL cnt1,cnt0:std_logic_vector(3 downto 0);

begin

process(clk)

begin

if(clr='0')then

cnt0<="0000";

cnt1<="0000";

elsif(clk'event and clk='1')then

if cnt1="0101" and cnt0="1000" then

co<='1';

cnt0<="1001";

elsif cnt0<"1001" then

cnt0<=(cnt0+1);

else

cnt0<="0000";

if cnt1<"0101"then

cnt1<=cnt1+1;

else

cnt1<="0000";

co<='0';

end if;

end if;

end if;

end if;

sec1<=cnt1;

sec0<=cnt0;

end process;

end sec;

仿真图如下:

2.分计数是由六十进制的计数器构成,生成元器件如下

Clk:设置分输入和秒进位的或输入

En:使能输入

Min1[3..0] min0[3..0]:分的高位显示,低位显示

Co:向时的进位输出

代码如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity minute is

port (clk,en:in std_logic;

min1,min0:out std_logic_vector(3 downto 0);

co:out std_logic);

end minute;

architecture min of minute is

SIGNAL cnt1,cnt0:std_logic_vector(3 downto 0);

begin

process(clk)

begin

if(clk'event and clk='1')then

if en='1' then

if cnt1="0101" and cnt0="1001" then

co<='1';

cnt0<="0000";

cnt1<="0000";

elsif cnt0<"1001" then

cnt0<=(cnt0+1);

else

cnt0<="0000";

cnt1<=cnt1+1;

co<='0';

end if;

end if;

end if;

min1<=cnt1;

min0<=cnt0;

end process;

end min;

仿真图如下:

3.时计数是由二十四进制的计数器构成,生成元器件如下

Clk:设置时间输入和分进位输入的或

en:使能端

h1[3..0] h0[3..0]:时的高位显示和低位显示

代码如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity hour is

port(clk,en:in std_logic;

h1,h0:out std_logic_vector(3 downto 0));

end hour;

architecture beha of hour is

signal cnt1,cnt0:std_logic_vector(3 downto 0);

begin

process(clk)

begin

if(clk'event and clk='1') then

if en='1' then

if cnt1="0010" and cnt0="0011" then

cnt1<="0000";

cnt0<="0000";

elsif cnt0<"1001" then

cnt0<=cnt0+1;

else

cnt0<="0000";

cnt1<=cnt1+1;

相关文档
最新文档